isTextPresent

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

isTextPresent

zlos7ar
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.
Reply | Threaded
Open this post in threaded view
|

Re: isTextPresent

softwaretestingforum
Administrator
try this -

public boolean isTextPresent(String expectedText) {

                        return driver.findElement(By.tagName('body')).getText().contains(expectedText);
        }
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: isTextPresent

zlos7ar
thanks it works