javascriptjavaseleniumxpathtextnode

How to access text in a website using Java Selenium


How to access text in a website using Java Selenium?

HTML snapshot:

enter image description here

Can someone explain to me how to access the demouser and email id using java selenium in the above picture

https://phptravels.com/demo this is the website im working on


Solution


I suppose you should be able to get these values from those elements values.
I.e. you can get the email input value with this:

WebElement email = driver.findElement(By.xpath("//div[.strong[text()='Email']]"));
String innerEmailvalue = email.getAttribute("value"); 

The same for the second element