Selenium Webdriverjs-createSession(... args)错误 [英] selenium webdriverjs - createSession(...args) error
问题描述
I installed webdriverjs on mac machine and tried to run a sample script from here as below
var webdriver = require('selenium-webdriver');
var browser = new webdriver.Builder().usingServer().withCapabilities({'browserName': 'chrome' }).build();
browser.get('http://en.wikipedia.org/wiki/Wiki');
browser.findElements(webdriver.By.css('[href^="/wiki/"]')).then(function(links){
console.log('Found', links.length, 'Wiki links.' )
browser.quit();
});
但是我收到错误
static createSession(...args) {}
^^^
SyntaxError: Unexpected token ...
我的Mac上已经安装了
node
node is already installed on my mac
推荐答案
根据上面的注释,在搜索了答案之后,才知道该错误是由于节点版本引起的.所以我不得不更新我的节点版本.
As per comment above and after searching for an answer , came to know that the error was due to node version. So i had to update my node version.
这是我遵循的过程.
当我尝试从brew update
brew doctor
brew upgrade node
When I tried to update node from brew update
brew doctor
brew upgrade node
它给了我错误Error: node not installed
,搜索后发现这是因为我的Mac上的节点是打包安装的,而不是通过homebrew
打包的,所以我不得不删除以前的安装并安装新的节点,然后我跟随此,来自
it gave me error Error: node not installed
, after searching came to know that this is because node on my mac was packaged installation and not through homebrew
so I had to remove previous installation and install fresh node and I followed this from here
注意:如果您单击上面的链接,并且当您执行./uninstall-node.sh
时,终端将停止,您可以按enter
键,然后脚本才会启动.之后,只需
Note: If you follow links above and when you do ./uninstall-node.sh
the terminal will stop for you to press enter
, only then the script will start. Afterwards just do
brew update && brew install node
安装新节点.现在node --version
给我v8.9.0
,并且升级节点后测试立即运行
brew update && brew install node
to install fresh node. Now node --version
gives me v8.9.0
and the the test runs immidiately after upgrading node
这篇关于Selenium Webdriverjs-createSession(... args)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!