windows732bit node.js 使用Selenium webdriver问题记录

    xiaoxiao2021-12-14  20

    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,火狐浏览器可打开百度搜索的网页。

    转载请注明原文地址: https://ju.6miu.com/read-971538.html

    最新回复(0)