Manual and Automated Testing
›
WebDriver (aka Selenium 2.0)
Search
everywhere
only in this topic
Advanced Search
isTextPresent
Classic
List
Threaded
♦
♦
Locked
3 messages
zlos7ar
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
isTextPresent
hi is there a way to build something like this but for finding text instead of element ?
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
thanks.
softwaretestingforum
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: isTextPresent
Administrator
try this -
public boolean isTextPresent(String expectedText) {
return driver.findElement(By.tagName('body')).getText().contains(expectedText);
}
~ seleniumtests.com
zlos7ar
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: isTextPresent
thanks it works
Free forum by Nabble
Edit this page