-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertGuest causes NoSuchElementException in the next call #911
Comments
Are you sure that the browser doesn't has any session based on previous tests/assertion? |
@crynobone I think so. Why should this else happen on a new installation? I also dropped my previous docker app with The issue is not, that the assertGuest fails (which would sound like the session you mentioned), but that the type command failed. So if it would a redirect and there is no input email field, both tests would fail. Right? |
Looking at the code against and I think I know the reason why.
You should change the code from: $browser->visit('/login')->assertGuest();
// to
$browser->assertGuest()->visit('/login'); |
@crynobone Oh wow. Respect. That solved it. Wow 👍 I just saw there are two different Normal Laravel HTTP testing seems to not has this side effect of changing the URL:
and the dusk version which changes the current URL: vendor/laravel/dusk/src/Concerns/InteractsWithAuthentication.php
So I don't know if it makes sense to adapt those? Probably there is a reason for the difference. Or maybe we could document it, that the dusk assertGuests changes the URL. Thanks anyway for the quick resolution. You are free to close this or take my thoughts into consideration. |
Submitted a PR #912 to redirect after assertion. This doesn't affect normal HTTP tests because that only mimic a Request, while Dusk tests require an actual browser to hit an actual request. |
If I use the
assertGuest
function, the next call totype
(into eg the email field) causes aFacebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body email"}
.If I remove the call to assertGuest() , it works again.
Used System
Steps to reproduce:
1) Install laravel
C:\Users\alexa\Desktop>
laravel new guesttest
Install Breeze, Sail, Dusk
C:\Users\alexa\Desktop>
cd guesttest
C:\Users\alexa\Desktop\guesttest>
composer require laravel/breeze --dev
C:\Users\alexa\Desktop\guesttest>
php artisan breeze:install
C:\Users\alexa\Desktop\guesttest>
npm install
C:\Users\alexa\Desktop\guesttest>
npm run dev
C:\Users\alexa\Desktop\guesttest>
php artisan sail:install
C:\Users\alexa\Desktop\guesttest>
composer require --dev laravel/dusk
C:\Users\alexa\Desktop\guesttest>
php artisan dusk:install
Files
.env (not changed by me)
tests\Browser\LoginTest.php
C:\Users\alexa\Desktop\guesttest>
php artisan dusk:make LoginTest
Test created successfully.
This testclass contains two functions with the same code, except, that one uses assertGuest , while the other does not.
Setting up sail (in Windows Terminal -> Ubuntu)
alex@DESKTOP-2DSRHN6:/mnt/c/Users/alexa/Desktop/guesttest$
vendor/bin/sail up -d
Run the tests
alex@DESKTOP-2DSRHN6:/mnt/c/Users/alexa/Desktop/guesttest$
sail dusk tests/Browser/LoginTest.php
As you can see, the first test works, the second does not. I have absolutely no clue why 🤷♂️
The text was updated successfully, but these errors were encountered: