user3061796
user3061796

Reputation: 553

Protractor E2E Testing Error: Cannot find module 'selenium-webdriver'

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');
  });
});

Upvotes: 12

Views: 16717

Answers (4)

Adam Spence
Adam Spence

Reputation: 3240

Try using the standalone option:

$ webdriver-manager start --standalone

Upvotes: 1

ForgetfulFellow
ForgetfulFellow

Reputation: 2632

When you type:

webdriver-manager

Into the terminal, the these helpful options appear:

webdriver-manager
Usage: webdriver-manager <command>
Commands:
  update: install or update selected binaries
  start: start up the selenium server
  status: list the current available drivers

Have you tried update, start, or status?

Upvotes: 1

cyberwombat
cyberwombat

Reputation: 40064

You need to install the node module:

npm i selenium-webdriver --save-dev

Upvotes: 8

glepretre
glepretre

Reputation: 8167

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

Upvotes: 2

Related Questions