Reputation: 19
How can I verify if a user sees on the screen a word, for instance “book” or “Book” ( on the webpage like https://www.amazon.com/gp/gw/ajax/s.html?ie=UTF8&ref_=nav_logo ? A script should check everything what a user sees including images (“title” and “alt”). The script should return True or False. How can I check the whole page using assert True, assert False ? Has anybody written something like this in Python ?
Upvotes: 1
Views: 992
Reputation: 2149
Yeah, I have written similar tests to make sure a page is properly loaded.
Hope it can help you out a bit.
Upvotes: 0
Reputation: 675
Get the complete text of the page .
WebDriver driver = new FirefoxDriver();
String bodyText = driver.findElement(By.tagName("body")).getText();
//if the word you would like to check is "Book"
boolean isWordPresent = bodyText.contains("Book");
Maintain a list of the words you wish to verify on the page and loop through the list.
Upvotes: 1