-1

I need to check that certain pages from a site, are https, like the login and personal info ones, so I think that an assert of the url with a ".contains" to check the existance of "https" in the url, but wanted to know if there's a better way to do this.

something like:

Public class mySite {

     WebDriver driver ;
     driver = new FirefoxDriver();
     String baseUrl = "http://www.google.com";

     driver.get(baseUrl);
     assertTrue(driver.getCurrentUrl().contains("https://"));
}

Thanks!

Lea2501
  • 311
  • 6
  • 22
  • 2
    I would use `startsWith` instead of `contains`, but this about it. – Guy Apr 18 '17 at 12:46
  • Possible duplicate of [Java: String representation of just the host, scheme, possibly port from servlet request](http://stackoverflow.com/questions/1104611/java-string-representation-of-just-the-host-scheme-possibly-port-from-servlet) – JeffC Apr 18 '17 at 17:32

1 Answers1

1

A more sensible one would be to use startsWith(String prefix) as it checks if the String starts with the prefix specified (in your case http). Since http occurs at the start of every URL, I suggest going with this.

Jayesh Doolani
  • 1,233
  • 10
  • 13