Codeception: Can not start codeception with chrome 59 in headless mode

Created on 7 Jun 2017  路  8Comments  路  Source: Codeception/Codeception

What are you trying to achieve?

I trying start codeception with chrome=59.0.3071.86 in headless mode by providing in args 'headless':

tests/acceptance.suite.yml:
      - WebDriver:
          url: https://crm.test
          browser: chrome
          window_size: maximize
          clear_cookies: false
          capabilities:
              chromeOptions:
                  prefs:
                    download.default_directory: '/var/www/crm/tests/_data/market_documents'
                  args:
                    ['disable-infobars', 'headless', 'disable-gpu']

What do you get instead?

Tests could not start and fall down with error:

[FacebookWebDriverExceptionUnknownServerException] unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: headless chrome=59.0.3071.86)
(Driver info: chromedriver=2.29,platform=Linux 4.10.13-1-ARCH x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.01 seconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'test_machine', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.10.13-1-ARCH', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.29, userDataDir=/tmp/.org.chromium.Chromium.FgXN4d}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=59.0.3071.86, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 588174371e59db7c773f8d7460987195

php -dxdebug.remote_enable=1 -dxdebug.remote_autostart=1 -dxdebug.idekey=PHPStorm vendor/bin/codecept run -f --steps acceptance Clients

Details

  • Codeception version: 2.3.2
  • PHP Version: 7.1.5 x86_64
  • Operating System: Linux test_machine 4.10.13-1-ARCH
  • Installation type: Composer
  • List of installed packages:
"codeception/codeception": "^2.3.2",
"codeception/verify": "~0.3.3",
  • Suite configuration:
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

class_name: AcceptanceTester
modules:
    enabled:
      - Db:
          cleanup: false
          dsn: 'mysql:host=localhost;dbname=db_test'
          password: 'PASSWORD'
          populate: false
          user: 'root'
      - WebDriver:
          url: https://crm.test
          browser: chrome
          window_size: maximize
          clear_cookies: false
          capabilities:
              chromeOptions:
                  prefs:
                    download.default_directory: '/var/www/app/tests/_data/downloads'
                  args:
                    ['disable-infobars', 'headless', 'disable-gpu']
      - \Helper\Acceptance
      - Asserts
      - Yii2:
          configFile: 'config/test.php'
          part: ORM
          cleanup: false # don't wrap test in transaction
          entryScript: 'index-dev.php'

Most helpful comment

Some of us were lucky to run Headless Chrome others didn't. Probably we will see better support in future Chrome versions.


For future readers:

Here is the working config for Codeception with Headless Chrome http://phptest.club/t/how-to-run-headless-chrome-in-codeception/1544

I'm closing this thread.

All 8 comments

It is an issue of chromedriver,
I found that you have to set useAutomationExtension capability to false.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1754
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1749#c8

Hello,

Have you success to use codeception with chrome 'headless' ? If yes do you use your suite.yml like that ?

    driver-chrome:
        modules:
            config:
              WebDriver:
                  browser: chrome
                  capabilities:
                    useAutomationExtension : false,
                    args:
                      ['disable-infobars', 'headless', 'disable-gpu']

And do you run selenium server with chrome driver linux ?

java -Dwebdriver.chrome.driver="chromedriver-linux64" -jar selenium-server-standalone-3.4.0.jar

Headless mode works for me with Linux Chrome 59 and chromedriver 2.29/2.30, but only if I disable the webdriver option window_size: maximize.
The capability useAutomationExtension : false doesn't help

@mirao your solution works. Just deleted window_size: maximize.

Working config:

class_name: AcceptanceTester
modules:
    enabled:
      - Db:
          cleanup: false
          dsn: 'mysql:host=localhost;dbname=crm_test'
          password: 'qweewq'
          populate: false
          user: 'root'
      - WebDriver:
          url: https://crm.test
          browser: chrome
          clear_cookies: false
          capabilities:
              chromeOptions:
                  prefs:
                    download.default_directory: '/var/www/crm/tests/_data/market_documents'
                  args:
                    ['disable-infobars', 'headless', 'disable-gpu']
      - \Helper\Acceptance
      - Asserts
      - Yii2:
          configFile: 'config/test.php'
          part: ORM
          cleanup: false # don't wrap test in transaction
          entryScript: 'index-dev.php'

I try to run test in docker image (https://github.com/SeleniumHQ/docker-selenium) . But I see an error:

[Facebook\WebDriver\Exception\UnknownServerException] unknown error: Chrome failed to start: exited normally (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.8.0-52-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.03 seconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'eb3058ce29ac', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.0-52-generic', java.version: '1.8.0_131' Driver info: driver.version: ChromeDriver

Without 'args' everything is OK.
My acceptance.suite.yml is:

class_name: AcceptanceTester

modules:
    enabled:
        - AngularJS
        - \Helper\Acceptance
    config:
        AngularJS:
            url: 'http://test.com'
            script_timeout: 120
            window_size: 1920x1080
            browser: 'chrome'
            pageload_timeout: 120

env:
    chromeRemote:
         modules:
            config:
                AngularJS:
                    browser: 'chrome'
                    port: 4444
                    host: **.***.**.***
                    capabilities:
                        chromeOptions:
                            prefs:
                                download.default_directory: '/var/www/crm/tests/_data/market_documents'
                            args:
                                ['disable-infobars', 'headless', 'disable-gpu']

With remote-debugging-port arg tests just hangs

args:
    ['disable-infobars', 'headless', 'disable-gpu', 'window-size=1920x1080', 'remote-debugging-port=9222']

@johndoejdg , thank You for your answer. But it does not solve my problem.
In case when I use container, and I add 'remote-debugging-port=9222' to config then nothing changed.
But if I run tests without container, without adding 'remote-debugging-port=9222' - test crashed on step:
$I->amOnUrl('http://test.com/test');
And if I run tests without container, with adding 'remote-debugging-port=9222' - test crashed on step:
'Scenario--'
(on very begining)

Some of us were lucky to run Headless Chrome others didn't. Probably we will see better support in future Chrome versions.


For future readers:

Here is the working config for Codeception with Headless Chrome http://phptest.club/t/how-to-run-headless-chrome-in-codeception/1544

I'm closing this thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DavertMik picture DavertMik  路  4Comments

allen0817 picture allen0817  路  3Comments

simara-svatopluk picture simara-svatopluk  路  3Comments

centerax picture centerax  路  4Comments

sasha-x picture sasha-x  路  3Comments