Dusk: Problem running Laravel Dusk test in Travis

Created on 9 Feb 2018  路  6Comments  路  Source: laravel/dusk

I'm trying to get Travis to run the Dusk test, but I always get an error. The tests work well on my local environment, but when Travis run the Test I get an error like this: NoSuchElementException: no such element: Unable to locate element: (see on travis)

.travis.yml

sudo: required
language: php
dist: trusty

php:
   - 7.2

addons:
   chrome: stable

install:
   - cp .env.example .env
   - travis_retry composer install --no-interaction --prefer-dist --no-suggest

before_script:
   - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
   - php artisan serve &

script:
   - php artisan dusk

Most helpful comment

474 -> Just saw your Issue. Currently facing the same Problem :$

All 6 comments

Hi @jaonoctus, did you find a solution?
Having same issue here...
Thanks

@dmarcos89 yup!

  • The command "cp .env.testing .env" failed and exited with 1 during
    (solved: https://github.com/jaonoctus/laravel-travis-ci-dusk/commit/eb7442bf1c93565313c46ec88ba97783c653214c)

  • The command "composer install --no-interaction --prefer-dist --no-suggest" failed 3 times.
    (solved: https://github.com/jaonoctus/laravel-travis-ci-dusk/commit/c95a30330cbf5485e21db83f0afc1ace795bced8)

  • Missing env variables.
    (solved: https://github.com/jaonoctus/laravel-travis-ci-dusk/issues/3)

  • NPM not installed.
    (solved: https://github.com/jaonoctus/laravel-travis-ci-dusk/commit/738acb111369160a422dd01cdaa098a0be007834)

After fix all this, my tests running now :smile:

my current .travis.yml file:

sudo: required
language: php
dist: trusty

php:
   - 7.2

addons:
   chrome: stable

install:
   - travis_retry composer install --no-interaction --prefer-dist --no-suggest
   - travis_retry npm install
   - npm run prod

before_script:
   - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
   - php artisan serve &

script:
   - php artisan dusk

Hi @jaonoctus , sorry i couldn't reply yesterday. First, thanks for your kind help!

I am still fighting with this... for some reason i believe that my APP_URL is causing errors and the paths are not being formed correctly.

This is a very basic test, which checks the login page appears:

public function testBasicExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')
                    ->assertSee('Login');
        });
    }
There was 1 failure:
1) Tests\Browser\ExampleTest::testBasicExample
Did not see expected text [Login] within element [body].
Failed asserting that false is true.

I am echoing the app url in travis fwrite(STDERR, 'App URL is: '.env('APP_URL')); and it is correctly showing http://127.0.0.1:8000

No idea on what else to try...Any other help will be much appreciated!!

Thanks!
Damian

474 -> Just saw your Issue. Currently facing the same Problem :$

I was missing the key:generate on the travis config.
Hope you can fix your issue too @StanBarrows .
Thanks

Was this page helpful?
0 / 5 - 0 ratings