I have previously installed selenium using 'npm install -g selenium-webdriver so all my projects were using global node-modules (set up on mac os). It worked! Then I have experimented with different JavaScript Test Automation frameworks. Now I want to start again from scratch, however when I am following the same steps as before to install selenium for webdriverJs automation it does not work.
#The steps that I took:#
- Run npm init (I did not change any values in the package.json)
- Run sudo npm install -g selenium-webdriver
- Run sudo npm install -g chromedriver
- Run sudo npm install -g geckodriver
- Verify that all modules were successfully created in /usr/local/lib/node_modules
- Verify that global modules are used by running the following simple script:
var webdriver = require('selenium-webdriver'),
//By = webdriver.By,
//until = webdriver.until;
var driver = new webdriver.Builder().forBrowser('chrome').build();
driver.get('https://www.google.com/');
#The Result#
Error: Cannot find module 'selenium-webdriver'
While I understand what the error is communicating (run the npm install selenium-webdriver to place node-modules with drivers inside of the Project), my intention is to use selenium-webdriver (plus chromedriver, geckodriver) globally for more projects.
How can I achieve that and enforce the project to use selenium globally rather than locally?
Thank You.