2

for an upcoming automation project I want to utilize Selenium for Firefox. I followed THIS GUIDE. Now when I want to run the mentioned script from within that guide using 'node /path/to/script/scriptName.js, a Firefox window pops up for a milisecond and closes immediately. The script so far is only copy/paste the contents from the guide.

Node/npm and webdriver are installed successfully. geckodriver is at '/home' directory and put into '$PATH'.

var webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until;

var driver = new webdriver.Builder()
    .forBrowser('firefox')
    .build();

driver.get('http://www.google.com');

driver.findElement(By.name('q')).sendKeys('webdriver');

driver.sleep(1000).then(function() {
  driver.findElement(By.name('q')).sendKeys(webdriver.Key.TAB);
});

driver.findElement(By.name('btnK')).click();

driver.sleep(2000).then(function() {
  driver.getTitle().then(function(title) {
    if(title === 'webdriver - Google Search') {
      console.log('Test passed');
    } else {
      console.log('Test failed');
    }
  });
});

driver.quit();

The console throws a lot of errors then, but I am not able to read out, what exactly is malfunctioning here. Can anyone tell me, what I might have missed?

node ~/projects/googleTest.js
(node:21344) UnhandledPromiseRejectionWarning: SessionNotCreatedError: Tried to run command without establishing a connection
    at Object.throwDecodedError (/home/ruphus/node_modules/selenium-webdriver/lib/error.js:550:15)
    at parseHttpResponse (/home/ruphus/node_modules/selenium-webdriver/lib/http.js:542:13)
    at Executor.execute (/home/ruphus/node_modules/selenium-webdriver/lib/http.js:468:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21344) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:21344) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:21344) UnhandledPromiseRejectionWarning: SessionNotCreatedError: Tried to run command without establishing a connection
    at Object.throwDecodedError (/home/ruphus/node_modules/selenium-webdriver/lib/error.js:550:15)
    at parseHttpResponse (/home/ruphus/node_modules/selenium-webdriver/lib/http.js:542:13)
    at Executor.execute (/home/ruphus/node_modules/selenium-webdriver/lib/http.js:468:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21344) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:21344) UnhandledPromiseRejectionWarning: SessionNotCreatedError: Tried to run command without establishing a connection
    at Object.throwDecodedError (/home/ruphus/node_modules/selenium-webdriver/lib/error.js:550:15)
    at parseHttpResponse (/home/ruphus/node_modules/selenium-webdriver/lib/http.js:542:13)
    at Executor.execute (/home/ruphus/node_modules/selenium-webdriver/lib/http.js:468:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21344) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:21344) UnhandledPromiseRejectionWarning: NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
    at promise.finally (/home/ruphus/node_modules/selenium-webdriver/lib/webdriver.js:726:38)
    at Object.thenFinally [as finally] (/home/ruphus/node_modules/selenium-webdriver/lib/promise.js:124:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21344) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)
erzwo
  • 173
  • 8

1 Answers1

1

I found a workaround in form of installing an older version of the selenium-webdriver in this threat.

npm i selenium-webdriver@3.6.0

erzwo
  • 173
  • 8