Quality Testing

Quality is delighting customers

How to verify an element after the successful page loading?

How to verify an element after the successful page loading?

Views: 67

Reply to This

Replies to This Discussion

Hi,

I usually use the following method for testing, if an element is present.

public boolean isElementPresent(By element) {
try {
driver.findElement(element);
return true;
} catch (NoSuchElementException e) {
return false;
}
}

The wait time can also be configured on the WebDriver:

webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);


I don't know any other way to do this. 

Thanks & Regards

  Hari

Hi,

If you are using selenium webdriver in any automated testing services company project, then you can use following code to verify the presence of a webelement on a webpage:

public boolean isElementPresent(String locator) {
        try {
            driver.findElement(By.xpath((locator)));
            return true;
        } catch (Exception e) {
            return false;
    }}

where locator = xpath of that web element.

Hope that helps.

Thanks

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2017   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service