尝试运行Selenium Webdriver(WebdriverJS)的示例测试时出现错误

拉维·卡纳萨格拉

我试图在文件中运行示例测试google_search_test.js位于\node_modules\selenium-webdriver\example我正在使用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

如果您全局安装了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秒。在我的系统上,默认超时时间太短,并且before在等待Firefox启动时测试失败

如果您想知道为什么selenium-webdriver不仅仅将Mocha列为依赖项,那是因为很可能无需使用Mocha就可以使用此软件包。因此,如果要使用该软件包,则由软件包的用户自行安装Mocha。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章