运行 cucumberjs ft.selenium、phantomjs、webdriverio 时出错
Error when running cucumberjs ft. selenium, phantomjs, webdriverio
我已经全局安装了 phantomjs npm install -g phantomjs
使用 java -jar selenium-standalone-2.52.0.jar
启动硒
像这样正确配置 cucumberjs 的 World
对象:
var options = {
//desiredCapabilities: { browserName: 'internet explorer' }, // WORK
//desiredCapabilities: { browserName: 'chrome' }, // WORK
desiredCapabilities: { browserName: 'phantomjs' }, // NOT WORK
waitforTimeout : 2000,
host: '127.0.0.1',
port: 4444
};
this.browser = webdriverio.remote(options);
它适用于 chrome & IE,但对 phantomjs 失败。
这是我从 Selenium 控制台得到的错误:
ERROR - org.apache.commons.exec.ExecuteException: Execution failed
(Exit value: -559038737. Caused by java.io.IOException: Cannot run
program "C:\Program Files (x86)\nodejs\phantomjs" (in directory "."):
CreateProcess error=193, %1 is not a valid Win32 application)
C:\Program Files (x86)\nodejs\phantomjs
存在。
我是否遗漏了 phantom / selenium 的任何配置?
嗯,终于在这个类似github issue中找到了原因。
C:\Program Files (x86)\nodejs\phantomjs
仅适用于 Linux 系统。看起来 phantomjs 的 webdriver 没有检查 window 应用程序上的 运行 的情况。
为了快速解决问题,我删除了文件 C:\Program Files (x86)\nodejs\phantomjs
,因此 selenium 会自动在同一文件夹上调用 phantomjs.bat。一切都会好的。
我已经全局安装了 phantomjs npm install -g phantomjs
使用 java -jar selenium-standalone-2.52.0.jar
像这样正确配置 cucumberjs 的 World
对象:
var options = {
//desiredCapabilities: { browserName: 'internet explorer' }, // WORK
//desiredCapabilities: { browserName: 'chrome' }, // WORK
desiredCapabilities: { browserName: 'phantomjs' }, // NOT WORK
waitforTimeout : 2000,
host: '127.0.0.1',
port: 4444
};
this.browser = webdriverio.remote(options);
它适用于 chrome & IE,但对 phantomjs 失败。
这是我从 Selenium 控制台得到的错误:
ERROR - org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "C:\Program Files (x86)\nodejs\phantomjs" (in directory "."): CreateProcess error=193, %1 is not a valid Win32 application)
C:\Program Files (x86)\nodejs\phantomjs
存在。
我是否遗漏了 phantom / selenium 的任何配置?
嗯,终于在这个类似github issue中找到了原因。
C:\Program Files (x86)\nodejs\phantomjs
仅适用于 Linux 系统。看起来 phantomjs 的 webdriver 没有检查 window 应用程序上的 运行 的情况。
为了快速解决问题,我删除了文件 C:\Program Files (x86)\nodejs\phantomjs
,因此 selenium 会自动在同一文件夹上调用 phantomjs.bat。一切都会好的。