我已经在全球范围内安装了phantomjs npm install -g phantomjs
使用java -jar selenium-standalone-2.52.0.jar
正确配置cucjs的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控制台获得的错误:
错误 - org.apache.commons.exec.ExecuteException:执行失败 (退出值:-559038737。由java.io.IOException引起:无法运行 程序“C:\ Program Files(x86)\ nodejs \ phantomjs”(在目录“。”中): CreateProcess error = 193,%1不是有效的Win32应用程序)
C:\Program Files (x86)\nodejs\phantomjs
存在。
我是否会错过幻影/硒的任何配置?
答案 0 :(得分:1)
好吧,最后我找到了类似github issue的原因。
C:\Program Files (x86)\nodejs\phantomjs
仅适用于Linux系统。看起来像phantomjs的webdriver没有检查在窗口应用程序上运行的情况。
要快速解决问题,请删除文件C:\Program Files (x86)\nodejs\phantomjs
,以便selenium会自动在同一文件夹上调用phantomjs.bat。一切都会好起来的。