Invalid URL: http:/

282 views
Skip to first unread message

Teemu

unread,
Apr 28, 2022, 8:49:10 AM4/28/22
to Selenium Users
Heya, have been trying to solve this for 3 days now, but i'm kind of clueless. This is an cloud server i'm facing this issue in while trying to run selenium headless. On my own pc and another pc i tested everything works as it should. Tried my own code and the example code found in (node_modules/selenium-browser/example/headless.js) with both geckodriver and chromedriver, but both return the same error.
Geckodriver and chromedriver both start individually correctly.

Selenium and node versions: selenium-...@4.1.1 & v18.0.0
Firefox: 99.0
OS: Ubuntu 20.04.4
Geckodriver: 0.31.0

Code:
const firefox = require('selenium-webdriver/firefox')
const { Builder, By, Key, until, logging } = require('selenium-webdriver')

const width = 640
const height = 480

logging.installConsoleHandler()
logging.getLogger('webdriver.http').setLevel(logging.Level.ALL);
var options = new firefox.Options().headless().windowSize({ width, height });

options.addArguments('--no-sandbox');

let driver = new Builder()
  .forBrowser('firefox')
  .setFirefoxService(
        new firefox.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
    )
  .setFirefoxOptions(options)
  .build()

driver
  .get('https://www.google.com/ncr')
  .then((_) =>
    driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
  )
  .then((_) => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
  .then(
    (_) => driver.quit(),
    (e) =>
      driver.quit().then(() => {
        throw e
      })
  )

Logs:
1651129741221    geckodriver    INFO    Listening on 127.0.0.1:45963
[2022-04-28T07:09:01Z] [FINEST] [webdriver.http] Translating command: newSession
[2022-04-28T07:09:01Z] [FINEST] [webdriver.http] Building HTTP request: {"method":"POST","path":"/session"}
[2022-04-28T07:09:01Z] [FINER] [webdriver.http.Executor] >>> POST /session
/root/node_modules/selenium-webdriver/http/index.js:51
    throw new Error('Invalid URL: ' + aUrl)
          ^

Error: Invalid URL: http:/
    at getRequestOptions (/root/node_modules/selenium-webdriver/http/index.js:51:11)
    at new HttpClient (/root/node_modules/selenium-webdriver/http/index.js:90:21)
    at getStatus (/root/node_modules/selenium-webdriver/http/util.js:38:18)
    at checkServerStatus (/root/node_modules/selenium-webdriver/http/util.js:76:14)
    at /root/node_modules/selenium-webdriver/http/util.js:74:5
    at new Promise (<anonymous>)
    at Object.waitForServer (/root/node_modules/selenium-webdriver/http/util.js:57:10)
    at /root/node_modules/selenium-webdriver/remote/index.js:251:24
    at new Promise (<anonymous>)
    at /root/node_modules/selenium-webdriver/remote/index.js:246:20

Michal

unread,
May 4, 2022, 9:56:16 AM5/4/22
to Selenium Users
Hey friend, I just ran into the same problem. The problem was coming out of an older library that was using selenium. The solution for me was downgrading Node.js to LTS version (16.15.0).

Hope this helps you too!

Dátum: štvrtok 28. apríla 2022, čas: 14:49:10 UTC+2, odosielateľ: Teemu

Teemu

unread,
May 9, 2022, 2:52:12 AM5/9/22
to Selenium Users
Thank you so much! This fixed the problem for me too.
Reply all
Reply to author
Forward
0 new messages