Tuesday, October 16, 2018

Selenium Firefox - Test using FindByElement( By.ClassName() )

This is very similar to the Test using FindByElement( By.XPath() ).

The change in this article is replacing the use of "xpath" obviously.

[Test Utility Class]
public static Boolean isDisclaimerDisplayed(WebDriver webDriver) {
    String modalTitle = webDriver.findByElement(By.className("modal-title").getText();
    return modalTitle.equalsIgnoreCase("Notice to All Users");
}

That's it. Cheers!

References
https://www.softwaretestingmaterial.com/how-to-locate-element-by-class-name-locator/
https://saucelabs.com/resources/articles/selenium-tips-css-selectors

No comments:

Post a Comment