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.
Asked
Active
Viewed 379 times
0

BoffinBrain
- 6,337
- 6
- 33
- 59

Ref
- 27
- 1
- 8
-
PLease share ur code – iamsankalp89 Sep 04 '17 at 12:02
-
my code is driver = new HtmlUnitDriver(); driver.get("http://testurl/apply/"); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); String exptUrl="http://exptUrl/help-with-travel"; String actUrl=hook.getHelpWtTravelPage().getPageUrl(); try { Assert.assertEquals(actUrl, exptUrl); – Ref Sep 04 '17 at 12:35
-
I am using same with google URL it show me same result in firefox and htmlunitdriver – iamsankalp89 Sep 04 '17 at 12:36
-
I don't found any issue, Please share specific problem or error – iamsankalp89 Sep 04 '17 at 12:47
-
As you see below html driver picks up "#" due to which it fails although i tried Thread.sleep, still fails.java.lang.AssertionError: http://citizen.blue.dev.nonprod.health.iosdigital.net:3000/apply/help-with-travel# - actual ur is not same as expt help with travel page url - http://citizen.blue.dev.nonprod.health.iosdigital.net:3000/apply/help-with-travel at org.testng.Assert.fail(Assert.java:94) at com.atwApply.stepDefinations.HelpWithTravelSteps.verifyHelpWithTravelPageDspld(HelpWithTravelSteps.java:28) at ✽.Then helpWithTravel page is displayed(a_viewSubmittedApplication.feature:10) – Ref Sep 04 '17 at 12:51
-
Then it is not possible match it assertequal , you have to used contains command for thar – iamsankalp89 Sep 05 '17 at 12:36
1 Answers
0
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/");
}}

iamsankalp89
- 4,607
- 2
- 15
- 36