Selenium (Java) Get FULL text from shortened displayed on page Selenium (Java) Get FULL text from shortened displayed on page selenium selenium

Selenium (Java) Get FULL text from shortened displayed on page


Try this using xpath :

WebElement hrefText=driver.findElement(By.xpath("//a[@href='http://www.example.com/es_es/spain/legal-notice.html']"));String text_hrefText=hrefText.getAttribute("href");System.out.println(text_hrefText);


You wanted to use getText() method, but getText() will be helpfull while we want to retrieve the innerHTML only. But if we use getAttribute() method, we will be able to pull out any of the attributes of the WebElement.

Now, to retrieve the full text of href attribute you can use the following line of code :

System.out.println(driver.findElement(By.xpath("//a[contains(@href,'example.com/es_es/spain/legal-notice')]")).getAttribute("href"));