error “[PHPUnit\Framework\Exception] Undefined index: ELEMENT” when running codeception with WebDriver

允我心安 提交于 2019-12-13 04:38:44

问题


I am trying to get codeceptions acceptance tests running with WebDriver. My current setup is the following:

  • Arch Linux
  • Chromium: Chromium 75.0.3770.80 Arch Linux
  • The included chromedriver-version: ChromeDriver 75.0.3770.80 (9a9aa15057b6b2cc0909bdcf638c0b65ecd516f2-refs/branch-heads/3770@{#948})
  • Selenium Server: Selenium server version: 3.14.0, revision: aacccce0

I am executing selenium by running env webdriver.chrome.driver="chromedriver" java -jar /usr/share/selenium-server/selenium-server-standalone.jar -port 5555 & When I run the acceptance tests however, I get the error [PHPUnit\Framework\Exception] Undefined index: ELEMENT for every test. Chromium starts correctly, loads the currect url but is unable to do anything else.

I researched the problem and found out, that there was a similar issue with geckodriver in the past. It could be fixed by passing -enablePassThrough false to selenium. The passthrough-mode was removed in selenium 3.9 however. The fix here was to simply switch to chromedriver. As I am already using chromedriver however, this doesn't work for me. Is it possible, that chromium doesn't support the w3c-specs? Is there any difference between Chromium and Chrome regarding support of Selenium?

The output of selenium: starting selenium:

11:39:58.474 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revi
11:39:58.478 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 5555
2019-06-07 11:39:58.689:INFO::main: Logging initialized @558ms to org.seleniumhq.jetty9.util.log.StdErrLog
11:39:58.895 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 5555

starting codeception-tests

11:40:24.577 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "chromeOptions": {
    "args": [
      "--disable-gpu"
    ]
  }
}
11:40:24.580 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server
Starting ChromeDriver 75.0.3770.80 (9a9aa15057b6b2cc0909bdcf638c0b65ecd516f2-refs/branch-heads/3770@{#948})
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
11:40:26.065 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
11:40:26.130 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 0c80ffc4e6c160d2817ab60ced6a279f (org.openqa.selenium.chrome.ChromeDriverService)

The acceptance tests should be fine as they run fine in my CI-Pipeline


回答1:


The php-webdriver library does not support w3c mode yet. You could pass w3c: false as a required capability to get legacy behaviour,
but a more reliable option is to use ChromeDriver v74.

More information can be found in this ticket https://github.com/facebook/php-webdriver/issues/469#issuecomment-499519728

Update: upgrading facebook/webdriver library to 1.7.0 version should fix this issue too.



来源:https://stackoverflow.com/questions/56491910/error-phpunit-framework-exception-undefined-index-element-when-running-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!