php - Codeception undefined index: ELEMENT error

424

i am using Codeception for acceptance testing. On my local pc i have no problems to run the tests with selenium and chromedriver. Until 1 week, it works also fine at my git, but now, there comes this error.

"[PHPUnit\Framework\Exception] Undefined index: ELEMENT"

local it is working fine without errors.

I already searched this error and found an tip, that i have to start selenium with "-enablepassthrough false". But this does not really works.

Before 1 week with all the same setup, it works fine.

this is my acceptance.suite.yml:

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: 'https://website.com' 
            host: 'selenium__standalone-chrome'
            port: 4444
            browser: chrome 
            window_size: 1920x1080 
554

Answer

Solution:

For Chrome/ChromeDriver v79 setting w3c to false inacceptance.suite.yml helped:

modules:
  enabled:
    - WebDriver:
        capabilities:
          chromeOptions:
            w3c: false
529

Answer

Solution:

This error message...

[PHPUnit\Framework\Exception] Undefined index: ELEMENT

...implies that the ChromeDriver'sclick() through Codeception is having an issue.

As per @reinholdfuereder's comment within the discussion facebook/php-webdriver - W3C WebDriver protocol support:

  • When using default W3C protocol, then the Codeception (v2.5.6) test fails withUndefined index: ELEMENT inwaitForElement() operation.
  • When using legacy protocol, then the test succeeds forwaitForElement() operation, which is followed by a seemingly also successfulclick() operation, but fails in thewaitForElementNotVisible() operation.
  • Codeception'sclick() operation is translated intoclickElement WebDriver command that is seemingly no more supported by ChromeDriver v75.

Solution

If you are using ChromeDriver v75.x and Chromium v75.x and you are seeing this error, you need to pass an additional chromeOptions w3c set to true.


Outro

You can find a couple of detailed discussion in:

175

Answer

Solution:

As @DebanjanB explained, setting the said option is a solution and this is what you get by updating facebook/php-webdriver to version >= 1.7.0

I think an even more solid solution (or habit) for your application is to use a specific docker image.

Your yaml makes me guess that you're using theselenium/standalone-chrome docker image. With their latest release (3.141.59-palladium) they updated the included Chrome version from74 to75 (see: https://github.com/SeleniumHQ/docker-selenium/releases).

Your local machine probably still runs an older version with Chrome 74 so no problems there. But whenever you rebuild the docker machine (e.g. when using some CI environment) you get the latest version. In this case a new Chrome version. Which "forces" you to also upgrade your php machine with a new facebook/php-webdriver.

I'd suggest to specify a version of the image to prevent these unwanted side effects, like

image: selenium/standalone-chrome:3.141.59-oxygen

or, if you've already made it run with Chrome 75,3.141.59-palladium.

People are also looking for solutions to the problem: How to enable php?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.