How to get Text from a WebElement in Selenium (java)

How to get Text from a WebElement in Selenium (java)

To get the text stored inside a text element (e.g. a p tag), use the WebElement method getText().

String firstElementText = driver.findElement(By.xpath("(//p)[2]")).getText();


See Working Example



Using Python

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.