我在设置 Selenium WebDriverJS 时遇到了一些问题。我的目标是使用 Javascript(节点)在 Chrome 浏览器上运行 selenium 测试。
我正在按照https://code.google.com/p/selenium/wiki/WebDriverJs以及https://code.google.com/p/chromedriver/wiki/GettingStarted上的说明进行操作
首先我下载了 chromedriver,然后在终端上运行它:
$ ./chromedriver
Starting ChromeDriver (v2.2) on port 9515
然后,我安装了 selenium-webdriver:
$ npm install selenium-webdriver
npm http GET https://registry.npmjs.org/selenium-webdriver
npm http 304 https://registry.npmjs.org/selenium-webdriver
selenium-webdriver@2.35.0 node_modules/selenium-webdriver
然后,我启动节点控制台并尝试构建 webdriver 实例
$ node
> var webdriver = require('selenium-webdriver')
undefined
> var driver = new webdriver.Builder().usingServer('http://localhost:9515/wd/hub').withCapabilities(webdriver.Capabilities.chrome()).build();
undefined
>
timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
UnknownCommandError: unknown command: wd/hub/session
at new bot.Error (/selenium/node_modules/selenium-webdriver/lib/atoms/error.js:109:18)
at Object.bot.response.checkResponse (/selenium/node_modules/selenium-webdriver/lib/atoms/response.js:103:11)
at /selenium/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:133:20
at /selenium/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/selenium-webdriver/lib/webdriver/promise.js:1438:20)
at notify (/selenium/node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
at notifyAll (/selenium/node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
at fulfill (/selenium/
现在我被封锁了。有人可以帮我吗?我在这里想念什么?
谢谢