简体   繁体   中英

Laravel Dusk Travis Ci

I'm running into a Problem running tests on Travics CI with Laravel Dusk.

Locally every test is performing as expected but as soon as I execute them on Travis CI, I get the following errors.

I also replaced the selectors of the type method to ( ->type('email', $user->email) ) or (->type('#email', $user->email) no changes.

Full Error Log from Travis

Any ideas?

Cheers, Stan

Error

  1. Tests\Browser\Tests\Auth\SignInTest::a_user_can_sign_in Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body textarea[name='#email']"} (Session info: headless chrome=64.0.3282.186) (Driver info: chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.4.0-101-generic x86_64)

sign in page

public function assert(Browser $browser)
    {
        $browser->assertPathIs($this->url());
    }

    public function signIn(Browser $browser, $email = null, $password = null)
    {
        $browser
            ->resize(1920, 1080)
            ->type('@login-email', $email)
            ->type('@login-password', $password)
            ->click('@login-button');
    }


    /**
     * Get the element shortcuts for the page.
     *
     * @return array
     */
    public function elements()
    {
        return [
        ];
    }

user can sign in method

 public function a_user_can_sign_in()
        {
            $path = route('login');
    
            $user = factory(User::class)->create([
    
                'name' => 'Max Mustermann',
                'email' => 'max.mustermann@testing.ch',
                'password' => bcrypt('password')
    
            ]);
    
            $this->browse(function ($browser) use ($path, $user) {
                $browser
                    ->visit(new SignInPage)
                    ->signIn($user->email, 'password')
                    ->assertPathIs('/backend/users/dashboard')
                    ->assertSeeIn('.navbar', $user->name);
            });
        }

Login email balde element

<div class="form-group row">

                            <div class="col-lg-8 offset-2">
                                <input   dusk="login-email"
                                        title="E-mail"
                                        placeholder="E-mail"
                                        id="email"
                                        type="email"
                                        class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}"
                                        name="email"
                                        value="{{ old('email') }}"
                                        required
                                        autofocus
                                >

                                @if ($errors->has('email'))
                                    <div class="invalid-feedback">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </div>
                                @endif
                            </div>
                        </div>

.env Dusk File

APP_NAME=Testing
    APP_ENV=testing
    APP_KEY=
    APP_DEBUG=true
    APP_LOG_LEVEL=debug
    APP_URL=http://do.testing.test
    
    DB_CONNECTION=pgsql
    DB_DATABASE=testing
    DB_USERNAME=postgres
    DB_PASSWORD=
    
    BROADCAST_DRIVER=log
    CACHE_DRIVER=array
    SESSION_DRIVER=database
    QUEUE_DRIVER=sync
    
    MAIL_FROM_NAME= Testing
    MAIL_FROM_ADDRESS=do@testing.test
    
    MAIL_DRIVER=log

Travis.yml File

sudo: true

dist: trusty

language: php

env:
  global:
    - CC_TEST_REPORTER_ID=

addons:
  chrome: stable

  code_climate:
    repo_token:
      secure:

php:
  - 7.2

services:
  - redis-server
  - postgres

before_script:
   - psql -c 'create database testing;' -U postgres
   - cp .env.travis .env
   - cp phpunit.travis.xml phpunit.xml

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

install:
   - travis_retry composer install --no-interaction --prefer-dist --no-suggest

   - cp .env.travis .env
   - cp phpunit.travis.xml phpunit.xml

   - php artisan key:generate

script:
  - phpunit
  - php artisan dusk

after_script:
  - vendor/bin/test-reporter

after_success:
  - chmod +x ./tests.sh; ./tests.sh

To make Dusk work with Travis CI you can update the APP_URL like this:

APP_URL=127.0.0.1:8000

Please see https://laravel.com/docs/6.x/dusk#continuous-integration for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM