
Untitled
By: a guest on
Aug 12th, 2012 | syntax:
None | size: 0.53 KB | hits: 8 | expires: Never
how can I check if some text exist or not in the page?
List<WebElement> list = driver.findElements(By.xpath("//*[contains(text(),'" + text + "')]"));
Assert.assertTrue("Text not found!", list.size() > 0);
String bodyText = driver.findElement(By.tagName("body")).getText();
Assert.assertTrue("Text not found!", bodyText.contains(text));
bodyText = self.driver.find_element_by_tag_name('body').text
self.assertTrue("the text you want to check for" in bodyText)
driver.getPageSource().contains("Text which you looking for");