gpt4 book ai didi

selenium - Webdriver 无法使用 phantomjs 创建 session

转载 作者:行者123 更新时间:2023-12-02 21:59:12 25 4
gpt4 key购买 nike

我已按照 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
}
}

按照功能所需的方式工作:{'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

以及 Protractor 错误 - 无法启动 WebDriver session 。

/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

任何指针都会有很大帮助。

谢谢

最佳答案

更新 Protractor 解决了问题,它使用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.jarphantomjs-2.0.0不兼容

<小时/>

TL;DR

在寻找我遇到的解决方案时

Downgrading back to version 2.43.1 fixes the issue, so i suspect a change in 2.44.0 has broken the ability to use PhantomJS on the grid.

位于Issue 8102: PhantomJS Doesn't Work on Selenium Grid 2.44.0

selenium-server-standalone目前位于/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

sudo curl -O https://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar

但是在启动webdriver-manager时,通过 webdriver-manager start命令,显示以下消息。

Selenium Standalone is not present. Install with webdriver-manager update --standalone

我刚刚下载了 selenium-server-standalone-2.43.1.jar ,但为什么webdriver-manager在提示吗?

查看 /usr/local/lib/node_modules/protractor 处的 webdriver-manager 代码,我注意到以下几点:

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"
}
}

关于更新 Protractor /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 .

<小时/>

现在,执行 protractor conf.js它的表现符合预期。

关于selenium - Webdriver 无法使用 phantomjs 创建 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29219075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com