[英]Getting Error while trying to run example test of Selenium Webdriver (WebdriverJS)
我正在尝试在位于\\node_modules\\selenium-webdriver\\example
文件google_search_test.js
运行示例测试。 我正在使用WebdriverJS并且只在我的系统中安装了selenium-webdriver
NPM软件包。
我已在命令提示符下移动到该路径位置并运行以下命令: node google_search_test.js
我收到以下错误:
错误描述:
Path\node_modules\selenium-webdriver\example>node google_search_test.js
Path\node_modules\selenium-webdriver\testing\index.js:184
exports.describe.skip = global.describe.skip;
^
TypeError: Cannot read property 'skip' of undefined
at Object.<anonymous> (C:\Users\kanasra\Desktop\Jaguars\Automation Testing\N
odeJs\node_modules\selenium-webdriver\testing\index.js:184:40)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Users\kanasra\Desktop\Jaguars\Automation Testing\N
odeJs\node_modules\selenium-webdriver\example\google_search_test.js:24:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
WebDriverJS (以npm包selenium-webdriver
分发)使用Mocha作为其测试驱动程序。 假设您位于node_modules
所在的目录中,则必须在Mocha中运行测试:
mocha -t 5000 node_modules/selenium-webdriver/example/google_search_test.js
如果您在全局npm -g install mocha
(使用npm -g install mocha
),则上述操作将起作用。 如果您在本地安装它(使用npm install mocha
),则必须提供本地二进制文件的路径。 在Unix系统上你会做:
node_modules/.bin/mocha -t 5000 node_modules/selenium-webdriver/example/google_search_test.js
我不知道npm在Windows系统上放置本地二进制文件的位置。
我建议使用-t 5000
将超时从默认的2秒增加到5秒。 在我的系统上,默认超时太短,并且在等待Firefox启动时, before
挂钩中测试失败。
如果你想知道为什么selenium-webdriver
不仅仅将Mocha列为依赖项,那是因为很有可能在不使用Mocha的情况下使用这个包。 因此,如果他们想要使用它,则由软件包的用户自行安装Mocha。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.