HtmlUnit Driver not able to pick correct URL

384 views Asked by At

I am trying to implement headless testing so used HtmlUnit Driver for that. It is working fine but fails on assert statement when I try to compare actual URL and expected URL. When I use HtmlUnit Driver, it picks up # at the end of URLs due to which condition fails although if I run on Firefox or chrome, works fine.

1

There are 1 answers

0
iamsankalp89 On

This is sample code which I have tried in Firefox and HtmlUnitDriver which is working fine:

@Test
public void Login()
{

    // driver = new FirefoxDriver();
     driver=new HtmlUnitDriver();
     driver.get("https://www.google.co.in/");
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
     String actualURl=driver.getCurrentUrl();
     Assert.assertEquals(actualURl, "https://www.google.co.in/");

}}