我已按照Setting up PhantomJS的说明进行操作。
请查看目录结构如下
吽 find . -name phantomjs; ll
./node_modules/.bin/phantomjs
./node_modules/phantomjs
./node_modules/phantomjs/bin/phantomjs
./node_modules/phantomjs/lib/phantom/bin/phantomjs
total 16
-rw-r--r-- 1 sarbbo Y\Domain Users 1269 Mar 23 12:02 specs.js
drwxr-xr-x 4 sarbbo Y\Domain Users 136 Mar 23 12:08 node_modules
-rw-r--r-- 1 sarbbo Y\Domain Users 204 Mar 23 12:25 conf.js
conf.js的内容如下所述。
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['specs.js'],
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path': require('phantomjs').path
}
}
根据capabilities: {'browserName': 'chrome'}
当protractor conf.js
被执行时,会显示以下错误:
webdriver-manager [ webdriver-manager 已使用webdriver-manager start
命令启动
12:41:41.043 INFO - Executing: [new session: Capabilities [{phantomjs.binary.path=/Users/sarbbo/GitHub/protractor/node_modules/phantomjs/lib/phantom/bin/phantomjs, count=1, browserName=phantomjs}]])
12:41:41.052 INFO - Creating a new session for Capabilities [{phantomjs.binary.path=/Users/sarbbo/GitHub/protractor/node_modules/phantomjs/lib/phantom/bin/phantomjs, count=1, browserName=phantomjs}]
12:41:41.054 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'rushpress-lm', ip: '10.73.199.247', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.2', java.version: '1.8.0_25'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:175)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:111)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:88)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:108)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)
at org.openqa.12:41:41.059 WARN - Exception: org.openqa.selenium.browserlaunchers.Proxies
和量角器 错误 - 无法启动WebDriver会话。
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
var template = new Error(this.message);
^
UnknownError: org.openqa.selenium.browserlaunchers.Proxies
at new bot.Error (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113:18)
at Object.bot.response.checkResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:152:24
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
at notifyAll (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:442:7)
at resolve (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:420:7)
at fulfill (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:535:5)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:149:22)
at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:123:30)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:294:22)
at DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:50:7)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:178:37)
at /usr/local/lib/node_modules/protractor/lib/runner.js:259:24
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
[launcher] Process exited with error code 1
任何指针都会有很大的帮助。
由于
答案 0 :(得分:3)
更新量角器解决了问题,它使用 selenium-server-standalone-2.45.0.jar
您可能需要使用sudo
执行以下命令。
npm i protractor -g
webdriver-manager update
更新2015年3月26日
以上适用于phantomjs-1.9.8但不适用于phantomjs-2.0.0。 我在本地更新了phantomjs version并从本地副本安装。
发生了同样的问题。看来, selenium-server-standalone-2.45.0.jar 与 phantomjs-2.0.0不兼容
<强> TL; DR 强>
在搜索我遇到的解决方案时
降级回版本2.43.1解决了这个问题,因此我怀疑2.44.0的更改已经破坏了在网格上使用PhantomJS的能力。
在Issue 8102: PhantomJS Doesn't Work on Selenium Grid 2.44.0
我系统中selenium-server-standalone
的{{1}}也是/usr/local/lib/node_modules/protractor/selenium
所以,我试图通过selenium-server-standalone-2.44.0.jar
寻找降级selenium-server-standalone
,但找不到合适的选项。
webdriver-manager
所以我在吽 webdriver-manager --help
Usage: webdriver-manager <command>
Commands:
update: install or update selected binaries
start: start up the selenium server
status: list the current available drivers
Options:
--out_dir Location to output/expect [default: "/usr/local/lib/node_modules/protractor/selenium"]
--seleniumPort Optional port for the selenium standalone server
--ignore_ssl Ignore SSL certificates [default: false]
--proxy Proxy to use for the install or update command
--alternate_cdn Alternate CDN to the binaries
--standalone Install or update selenium standalone [default: true]
--chrome Install or update chromedriver [default: true]
--ie Install or update IEDriver [default: false]
Please specify one command
selenium-server-standalone-2.43.1.jar
下载了curl
/usr/local/lib/node_modules/protractor/selenium
但是,在启动 webdriver-manager 时,通过sudo curl -O https://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar
命令显示以下消息。
webdriver-manager start
我刚刚下载Selenium Standalone is not present. Install with webdriver-manager update --standalone
,但为什么selenium-server-standalone-2.43.1.jar
抱怨?
在webdriver-manager
查看 webdriver-manager 代码时,我注意到以下内容:
/usr/local/lib/node_modules/protractor
它试图根据if (!binaries.standalone.exists) {
console.error('Selenium Standalone is not present. Install with ' +
'webdriver-manager update --standalone');
process.exit(1);
}
selenium-server-standalone
的存在
以下是/usr/local/lib/node_modules/protractor/config.json
/usr/local/lib/node_modules/protractor/config.json
更新量角器 {
"webdriverVersions": {
"selenium": "2.44.0",
"chromedriver": "2.14",
"iedriver": "2.44.0"
}
}
已更新为
/usr/local/lib/node_modules/protractor/config.json
然后执行{
"webdriverVersions": {
"selenium": "2.45.0",
"chromedriver": "2.14",
"iedriver": "2.45.0"
}
}
已安装的webdriver-manager update
以及selenium-server-standalone-2.45.0.jar
。
现在,在执行chromedriver
时,它按预期执行。