Error trying to run Selenium Webdriver test sample (WebdriverJS)

I am trying to run a test example in the google_search_test.js file located in \node_modules\selenium-webdriver\example . I use WebdriverJS and only installed the selenium-webdriver NPM package on my system.

I node google_search_test.js this path to the command line and node google_search_test.js following command: node google_search_test.js

I got the following error:

enter image description here

Error Description:

 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) 
+6
source share
1 answer

WebDriverJS (distributed as the npm selenium-webdriver ) uses Mocha as a test driver. Assuming you are in the directory where node_modules is located, you should run the test in Mocha:

 mocha -t 5000 node_modules/selenium-webdriver/example/google_search_test.js 

The above will work if you installed Mocha globally (with npm -g install mocha ). If you install it locally (with npm install mocha ), you must specify the path to the local binary. On Unix systems, you must:

 node_modules/.bin/mocha -t 5000 node_modules/selenium-webdriver/example/google_search_test.js 

I do not know where npm places local binaries on Windows systems.

I suggest using -t 5000 to increase the timeout from the default from 2 seconds to 5 seconds. On my system, the default timeout is too short, and the test fails before before waiting for Firefox to start.

If you are wondering why selenium-webdriver does not just list Mocha as a dependency, it is because it is possible to use this package without using Mocha. Thus, users of the package can install Mocha themselves if they want to use it.

+9
source

Source: https://habr.com/ru/post/978931/


All Articles