Using getText() method, we can get the text of the element.
That is,
WebElement gButton = driver.findElement(By.name("btnK"));
String gButtonText = gButton.getText();
System.out.println("The Google search button's display text is "+gButtonText);
The getText() method gets the text of an element. This uses either the textContent (Mozilla-like browsers) or the innerText (IE-like browsers) of the element, which is the rendered text shown to the user.
No comments:
Post a Comment