If it is still your problem you can try to add ->waitFor(element) maybe page is not rendered properly yet. You can verify this by checking screenshots for example... Hope this helps...
Dusk: Two tests not working together, but individually.
I have a Dusk test file with the following content:
<?php
namespace Tests\Browser;
use Illuminate\Support\Facades\Auth;
use Tests\Browser\Pages\Login;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class UserTest extends DuskTestCase
{
use DatabaseMigrations;
//<editor-fold desc="Login">
/** @test */
public function a_registered_user_can_log_in()
{
factory('App\User')->create(['username' => 'John']);
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->type('username', 'John')
->type('password', 'secret')
->click('#submit')->assertPathIs('/home');
});
}
/** @test */
function a_wrong_username_or_password_is_gives_a_human_readable_error_message()
{
factory('App\User')->create(['username' => 'RealName']);
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->type('username', 'WrongName')
->type('password', 'secret')
->click('#submit')
->assertSee('These credentials do not match our records.');
});
}
//</editor-fold>
}
When I run the tests individually (using --filter), they run perfectly fine. But if I run them all together, the second test fails to find the requested elements (NoSuchElementsException). It also doesn't help when I create a Page class for the Login Page and define the elements there.
The whole thing does work if I call php artisan dusk --process-isolation, but of course that takes much longer, as all tests are executed one after the other. It also works when I put the tests in different files, but that also executes them one after the other, and it doesn't feel all that good from a coding standpoint to have only one test per file.
Does anyone of you know how I can run the tests simultaneously and have them complete properly?
Please or to participate in this conversation.