Skip to content
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

Test run in headless chrome is not working #6705

Open
gafi9 opened this issue Oct 19, 2023 · 2 comments
Open

Test run in headless chrome is not working #6705

gafi9 opened this issue Oct 19, 2023 · 2 comments

Comments

@gafi9
Copy link

gafi9 commented Oct 19, 2023

What are you trying to achieve?

I've wanted to run a test in headless Chrome, but it seems like the capabilities part of the web driver module is not recognized. Below you can see the setup I have.
I've tried the recommendation in the official documentation https://codeception.com/docs/modules/WebDriver#Headless-Chrome-Browser and I've tried the tips in #4699 and in SeleniumHQ/selenium#886 (comment) as well, but neither worked.

Steps:

  1. I've started the chrome driver with selenium-standalone start --singleDriverStart=chrome
12:53:40.739 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
12:53:40.747 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
12:53:42.030 INFO [NodeOptions.getSessionFactories] - Detected 8 available processors
12:53:42.055 INFO [NodeOptions.discoverDrivers] - Driver(s) already present on the host: 1
12:53:42.082 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome","goog:chromeOptions": {"args": [ "--remote-allow-origins=*" ] } } 8 times (Host)
12:53:42.172 INFO [Node.<init>] - Binding additional locator mechanisms: relative
12:53:42.561 INFO [Standalone.execute] - Started Selenium Standalone 4.9.0 (revision d7057100a6): http://url
  1. I ran the test with php vendor/bin/codecept run --debug -> Browser started and the test runs in headed mode

Details

  • Codeception version: 5.0.11
  • PHP Version: 8.2.11
  • Operating System: Windows 10
  • Installation type: Composer
  • List of installed packages (composer show)
antavo/escher-php                  1.2.1    Library for HTTP request signing (PHP implementation)
behat/gherkin                      v4.9.0   Gherkin DSL parser for PHP
codeception/codeception            5.0.11   BDD-style testing framework
codeception/lib-asserts            2.1.0    Assertion methods used by Codeception core and Asserts module
codeception/lib-innerbrowser       4.0.0    Parent library for all Codeception framework modules and PhpBrowser
codeception/lib-web                1.0.2    Library containing files used by module-webdriver and lib-innerbrowser or module-phpbrowser
codeception/lib-xml                1.0.1    Files used by module-rest and module-soap
codeception/module-asserts         3.0.0    Codeception module containing various assertions
codeception/module-phpbrowser      3.0.0    Codeception module for testing web application over HTTP
codeception/module-rest            3.3.2    REST module for Codeception
codeception/module-webdriver       4.0.0    WebDriver module for Codeception
codeception/stub                   4.1.2    Flexible Stub wrapper for PHPUnit's Mock Builder
graham-campbell/result-type        v1.1.1   An Implementation Of The Result Type
guzzlehttp/guzzle                  7.8.0    Guzzle is a PHP HTTP client library
guzzlehttp/promises                2.0.1    Guzzle promises library
guzzlehttp/psr7                    2.6.1    PSR-7 message implementation that also provides common utility methods
justinrainbow/json-schema          v5.2.13  A library to validate a json schema.
masterminds/html5                  2.8.1    An HTML5 parser and serializer.
myclabs/deep-copy                  1.11.1   Create deep copies (clones) of your objects
nikic/php-parser                   v4.17.1  A PHP parser written in PHP
phar-io/manifest                   2.0.3    Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    3.2.1    Library for handling version information and constraints
php-webdriver/webdriver            1.15.0   A PHP client for Selenium WebDriver. Previously facebook/webdriver.
phpoption/phpoption                1.9.1    Option Type for PHP
phpunit/php-code-coverage          10.1.7   Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          4.1.0    FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                4.0.0    Invoke callables with a timeout
phpunit/php-text-template          3.0.1    Simple template engine.
phpunit/php-timer                  6.0.0    Utility class for timing
phpunit/phpunit                    10.4.1   The PHP Unit Testing framework.
psr/container                      2.0.2    Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher               1.0.0    Standard interfaces for event handling.
psr/http-client                    1.0.3    Common interface for HTTP clients
psr/http-factory                   1.0.2    Common interfaces for PSR-7 HTTP message factories
psr/http-message                   2.0      Common interface for HTTP messages
psy/psysh                          v0.11.21 An interactive shell for modern PHP.
ralouphie/getallheaders            3.0.3    A polyfill for getallheaders.
sebastian/cli-parser               2.0.0    Library for parsing CLI options
sebastian/code-unit                2.0.0    Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 3.0.0    Looks up which function or method a line of code belongs to
sebastian/comparator               5.0.1    Provides the functionality to compare PHP values for equality
sebastian/complexity               3.1.0    Library for calculating the complexity of PHP code units
sebastian/diff                     5.0.3    Diff implementation
sebastian/environment              6.0.1    Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 5.1.1    Provides the functionality to export PHP variables for visualization
sebastian/global-state             6.0.1    Snapshotting of global state
sebastian/lines-of-code            2.0.1    Library for counting the lines of code in PHP source code
sebastian/object-enumerator        5.0.0    Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         3.0.0    Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        5.0.0    Provides functionality to recursively process PHP variables
sebastian/type                     4.0.0    Collection of value objects that represent the types of the PHP type system
sebastian/version                  4.0.1    Library that helps with managing the version number of Git-hosted PHP projects
softcreatr/jsonpath                0.8.3    JSONPath implementation for parsing, searching and flattening arrays
symfony/browser-kit                v6.3.2   Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically
symfony/console                    v6.3.4   Eases the creation of beautiful and testable command line interfaces
symfony/css-selector               v6.3.2   Converts CSS selectors to XPath expressions
symfony/deprecation-contracts      v3.3.0   A generic function and convention to trigger deprecation notices
symfony/dom-crawler                v6.3.4   Eases DOM navigation for HTML and XML documents
symfony/event-dispatcher           v6.3.2   Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts v3.3.0   Generic abstractions related to dispatching event
symfony/finder                     v6.3.5   Finds files and directories via an intuitive fluent interface
symfony/polyfill-ctype             v1.28.0  Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme     v1.28.0  Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-normalizer   v1.28.0  Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring          v1.28.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php80             v1.28.0  Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/process                    v6.3.4   Executes commands in sub-processes
symfony/service-contracts          v3.3.0   Generic abstractions related to writing services
symfony/string                     v6.3.5   Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/var-dumper                 v6.3.5   Provides mechanisms for walking through any arbitrary PHP variable
symfony/yaml                       v6.3.3   Loads and dumps YAML files
theseer/tokenizer                  1.2.1    A small library for converting tokenized PHP source code into XML and potentially other formats
vlucas/phpdotenv                   v5.5.0   Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
  • Suite configuration:
actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: 'https://loyalty.testauto.antavo.com'
            browser: chrome
            capabilities:
                chromeOptions:
                    args: ["--headless", "--disable-gpu"]
        - REST:
              depends: PhpBrowser
              part: Json
        - Asserts
        - Tests\Support\Helper\DataStore

# add Codeception\Step\Retry trait to AcceptanceTester to enable retries
step_decorators:
    - Codeception\Step\ConditionalAssertion
    - Codeception\Step\TryTo
    - Codeception\Step\Retry
    - Codeception\Step\AsJson

gherkin:
    contexts:
        path: tests/Support/Step
        namespace_prefix: Tests\Support\Step
        default:
            - Tests\Support\AcceptanceTester
@den1a
Copy link

den1a commented Dec 14, 2023

Hi. I have a similar problem. I couldn't solve it. Try this option as a temporary solution

https://github.com/webdriverio/selenium-standalone/blob/HEAD/docs/xvfb.md

Good luck

@fridtjof
Copy link

The chromeOptions key was renamed to goog:chromeOptions in Selenium 3.8, see e.g. here #5349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants