What error does this line return when I pass a URL without HTTPS or HTTP
driver.get("www.google.com");
It was asked to a fresher in his interview.
What error does this line return when I pass a URL without HTTPS or HTTP
driver.get("www.google.com");
It was asked to a fresher in his interview.
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 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.
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.
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”.