Error: Cannot find module 'selenium-webdriver'
I have installed protractor and selenium-webdriver globally using npm install -g protractor webdriver-manager update
var webdriver = require('selenium-webdriver');
describe('modes of failure', function() {
it('should fail to find a non-existent element', function() {
browser.get('index.html#/form');
// Run this statement before the line which fails. If protractor is run
// with the debugger (protractor debug debugging/conf.js), the test
// will pause after loading the webpage but before trying to find the
// element.
browser.debugger();
// This element doesn't exist, so this fails.
var nonExistant = element(by.binding('nopenopenope')).getText();
});
it('should fail to use protractor on a non-Angular site', function() {
browser.get('http://www.google.com');
}, 20000);
it('should fail an assertion', function() {
browser.get('index.html#/form');
var greeting = element(by.binding('{{greeting}}'));
expect(greeting.getText()).toEqual('This is not what it equals');
});
});
You need to install the node module:
npm i selenium-webdriver --save-dev
Did you try to remove the var webdriver = require('selenium-webdriver');
?
You shouldn't need it, you can access it in your test via browser
browser
this is the a wrapper around an instance of webdriver. Used for navigation and page-wide information.
(quoted from Getting started - Protractor docs)
If you've already installed the Selenium standalone server using webdriver-manager update
, and started it with webdriver-manager start
, all you have to do is to run your tests using
protractor path/to/your/protractor-conf.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With