Reputation: 825
The scenarios is when you click on submit button on page A, it redirects you to Page B most of the time but there are some conditions when it will take back you to Page A without going to Page B.
Also, there can be frontend validation errors which sometimes prevent the submit button to take control to the next page.
So I exactly want to verify that when I clicked on submit button it has taken me to Page B or if page A is displayed again it is not because of validation errors but it is the fresh page came after redirection.
Upvotes: 1
Views: 905
Reputation: 11
1.Check for the change in the url of the page.
2.Compare the content of the page before and after clicking the submit button.
Upvotes: 0
Reputation: 2267
There are two ways to make sure that we have successfully navigated to page B after clicking submit button in page A:
Upvotes: 1
Reputation: 7708
Make sure your URL get changes after click on submit button If Yes the you can use below code
String currentPage=driver.getCurrentUrl();
driver.findElement(By.yourLocatorForSubmitButton).click();
String newPage = driver.getCurrentUrl();
if(currentPage.equals(newPage))
{
System.out.println("On Same Page");
// Here you perform your further action if there is some validation error then get those validation and fullfill the condition
}
else
{
//carry on your further action comes on new page
}
Upvotes: 1