What error does this line return when I pass a URL without HTTPS or HTTP


It was asked to a fresher in his interview.

  • 1
    Have you tried this statement in your script? – Himanil Gupta Nov 12 '19 at 7:08
  • 1
    I do not see any value in this, OP wants others to run a piece of code for him and paste the error. – Moro Nov 13 '19 at 12:03

I think it is a stupid question to ask in an interview, because it asks a very specific detail of how to use WebDriver that I have not really thought about in the 10 years I am using Selenium, but this might a great answer:

  • I don't know, but I could try and see what happens. Why do you ask? Did you have problems with this in the past?

I have just tried removing HTTPS with WebDriver C#, but it uses driver.Navigate().GoToUrl(), it gives:

Message: OpenQA.Selenium.WebDriverException : invalid argument
(Session info: chrome=77.0.3865.120)

I think it might be different depending on language and or browser driver implementation.

There might be a risk that leaving out the HTTPS it could default to HTTP, thus not testing the HTTPS version of the site. I do think HTTP should always redirect to HTTPS and you should only test one version.

| improve this answer | |
  • Besides the browser itself, there are extensions and configurations to always for HTTPS. The answer is very contextual. – João Farias Nov 12 '19 at 8:53
  • You already tried to explain an answer to this question (which shows why the question is not stupid!) – masood ghz Nov 12 '19 at 9:47
  • @masoodghz Maybe, I have updated my answer to explain why I think it is a stupid question :) – Niels van Reijmersdal Nov 12 '19 at 10:56

This question is about WebDriver W3C specification. As per the specification any implementation has to follow:

If url is not an absolute URL or is not an absolute URL with fragment or not a local scheme, return error with error code invalid argument.

| improve this answer | |

If you try to open a URL without http or https (for e.g. driver.get(“www.facebook.com”);), get() method will throw an error “org.openqa.selenium.WebDriverException“.

It will also gives error message as “Cannot navigate to invalid URL”.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.