Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor e2e throwing webdriver is not defined

I had my protractor running untill few days ago when i started encountering:

Using the selenium server at http://localhost:4444/wd/hub
 **** UNCAUGHT EXCEPTION ****
Error: connect ECONNREFUSED
    at exports._errnoException (util.js:682:11)
    at Object.afterConnect [as oncomplete] (net.js:947:19)
 ****************************
 **** UNCAUGHT EXCEPTION ****
Error: socket hang up
    at createHangUpError (_http_client.js:182:15)
    at Socket.socketCloseListener (_http_client.js:214:23)
    at Socket.EventEmitter.emit (events.js:120:20)
    at TCP.close (net.js:459:12)
 ****************************

on further digging using my custom callback method e.message printed:

Error:: webdriver is not defined

/home/workspace/desktop/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1702
      throw error;
            ^
ReferenceError: webdriver is not defined

I tried installing selenium web driver using npm install selenium-webdriver but this did not help, also tried npm install for protractor but nothing seems to work here

Any help in this regard is highly appreciated.

-Vaibhav

like image 244
vaibhav Avatar asked Apr 14 '14 06:04

vaibhav


1 Answers

I just ran into a similar issue, so I thought I'd share a solution I worked out.

After a little digging, I found a thread on accessing the current webdriver instance. Unfortunately, that doesn't give access to the actual webdriver object (it's just an instance of webdriver.WebDriver). What eventually worked for me was installing selenium-webdriver using npm and then putting this at the top of my test spec file:

var webdriver = require('selenium-webdriver');

I then had access to the webdriver namespace in that spec file.

like image 61
Heston Liebowitz Avatar answered Oct 27 '22 21:10

Heston Liebowitz