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 theinnerText
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 thegetText()
function:driver.get("https://www.google.com"); System.out.println(driver.findElement(By.id("_eEe")).getText());
JavaScriptExecutor
is a Selenium interface to execute JavaScripts that returns theinnerText
attribute of a hidden element. It is important...