Reputation: 23
I am clicking on a particular button/link which redirects to another page, I just want to verify that it is redirecting me to the correct page.
I am using Java and onClick()
.
Upvotes: 1
Views: 5260
Reputation: 5347
expectedURL="{expected URL}";
driver.findElement(By.xpath("xpath for the button").click();
String redirectURL=driver.getCurrentUrl();
Assert.assertEquals(redirectURL,expectedURL);
Upvotes: 1
Reputation: 1643
browser.getCurrentUrl()
Upvotes: 1