问题
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
回答1:
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.
回答2:
I have found the solution to it however not very convinced about the reasoning. My node version was latest and when I switched to node version v0.10.26 the e2e protractor test cases started working again.
来源:https://stackoverflow.com/questions/23053661/protractor-e2e-throwing-webdriver-is-not-defined