windows7 32bit node.js 使用Selenium webdriver问题记录

npm install selenium-webdriver
安装 selenium-webdriver之后,在一个javascript 文件 first_example.js中复制下面内容:

var webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until;

var driver = new webdriver.Builder()
    .forBrowser('firefox')
    .build();

driver.get('http://www.baidu.com');


运行node  first_example.js出现下面问题:

static createSession(...args) {}
                       ^^^
SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/ubuntu/testenvoy/controllers/test/all.js:2:17)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)


据查询是node.js版本问题,需要升级node版本到最新。升级到最新版本的方法是:

npm install –g n

n latest

但是,在执行npm install –g n之后,出现下面信息:

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "n"
npm ERR! node v5.2.0
npm ERR! npm  v3.3.12
npm ERR! code EBADPLATFORM


npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your operating system or architecture: n@2.1
.4
npm ERR! notsup Valid OS:    !win32
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: ia32


npm ERR! Please include the following file with any support request:
npm ERR!     C:\Program Files\nodejs\npm-debug.log

难道n不支持 windows 32bit的系统??也没有详细追究,直接在node官网下载最新的版本v6.9.1,安装到原来安装node的目录,覆盖旧版本nodejs.


运行node first_example.js,出现:

Error: The geckodriver.exe executable could not be found on the current PATH. Pl
ease download the latest version from https://github.com/mozilla/geckodriver/rel
eases/WebDriver and ensure it can be found on your PATH.


Firefox 47+的版本要下载使用geckodriver(.exe),下载geckodriver-v0.11.1-win32.zip到nodejs目录,解压之,nodejs的目录已经在系统PATH变量中。

运行node first_example.js,火狐浏览器可打开百度搜索的网页。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值