I want to check whether the URL's are https or not?
For this:
I need to pass URL's without http/https.
eg: driver.get("google.com");
and driver.get("http://google.com");
Can anyone help me out please. Is it possible to automate such scenario's ?
Thanks in advance.
driver.get()
requires valid URL that starts with "http"/"https". However, driver.get("http://www.google.com")
will navigate to "https://www.google.com"
For the parsing you can use startsWith
method
String url = driver.getCurrentUrl();
if (url.startsWith("https")) {
// url is https
}
else {
// url is http
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With