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.
Louis source share