Selenium - 代码 - chrome问题

C R*_*hmi 2 google-chrome selenium-rc selenium-webdriver

在selenium服务器中使用codeception在chrome上运行测试时,我会随机获得以下错误:

WebDriver\Exception\UnknownError: The current platform is not supported: LINUX

WebDriver\Exception\UnknownError: Unable to find executable for product Opera Desktop

WebDriver\Exception\UnknownError: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable; for more information, see https://github.com/ariya/phantomjs/wiki. The latest version can be downloaded from http:\//phantomjs.org/download.html
Run Code Online (Sandbox Code Playgroud)

当给予firefox时,它工作正常.

运行selenium的命令:

java -jar selenium-server-standalone-2.31.0.jar -browser googlechrome
Run Code Online (Sandbox Code Playgroud)

以下是acceptance.yml内容

class_name: WebGuy
modules:
  enabled:
    - Selenium2
    - WebHelper
  config:
    Selenium2:
      url: 'http://www.google.com'
      browser: googlechrome
  delay: 350
Run Code Online (Sandbox Code Playgroud)

小智 9

要使用Chrome运行代码,请使用以下命令acceptance.suite.yml:

class_name: WebGuy
modules:
  enabled:
    - Selenium2
    - WebHelper
  config:
    Selenium2:
      url: 'http://www.google.com'
      browser: chrome
      delay: 350
Run Code Online (Sandbox Code Playgroud)

请注意,我将配置中的浏览器从更改googlechromechrome.

另外,使用以下命令启动Selenium2:

java -Dwebdriver.chrome.driver=./chromedriver -jar selenium-server-standalone-2.31.0.jar

请注意,启动selenium时无需指定浏览器.

你可以在这里下载chromedriver .您还应该更新您的selenium独立服务器; 你可以从这里获得最新版本.