Reputation: 31
How can we tally data values which are in different web pages using selenium web driver? What are the codes ? Those data are in same website but two web pages. I want To Tally Total sale using Invoice And Return Sale
Upvotes: 1
Views: 82
Reputation: 17593
You can use driver.navigate()
to hit the first desire URL and then save the value in a string variable, now again navigate to the 2nd required page and save the value. Now compare it
driver.navigate().to("https://www.iana.org/domains/reserved");
String country =driver.findElement(By.xpath("//*[@id=\"arpa-table\"]/tbody/tr[1]/td[3]")).getText();
driver.navigate().to("https://www.iana.org/numbers");
String country2 =driver.findElement(By.xpath("//*[@id=\"rir-map\"]/table/tbody/tr[1]/td[1]/a")).getText();
if(country.equalsIgnoreCase(country2))
{
System.out.println("Country are similer");
}
else
{
System.out.println("country are not similer");
}
I have used simple if else to validate the similarities.
But you can use Assert of TestNG or Junit to validate it
Assert.assertEquals(country, country1);
refer the below URL for more info :-
http://www.seleniumeasy.com/testng-tutorials/assertions-in-testng
Hope it will help you :)
Upvotes: 1