WebElement functions

WebElement is an HTML element that helps the users to drive automation tests. Selenium WebDriver provides well-organized web page interactions through WebElements, such as locating elements, getting attribute properties, asserting text present in WebElement, and more. However, to interact with hidden elements in a web page, it is necessary to unhide the hidden elements first. Let's discuss Selenium WebElement functions further:

  • getText(): This function delivers the innerText attribute of WebElement. The following is the syntax for this function:
    driver.findElement(By.locatorType("path")).getText();

    The following is an example on the Google page that returns the innerText attribute of a Google search button using the getText() ...

Get Selenium Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.