power_settings_new

How to print text between p Tags

by
+1 vote
78 views
<p>
  Statements inside About
</p>
 
 
How to print Text inside p(Paragraph) Tags using Selenium Webdriver(JAVA).
 
In the above example   "Statements inside About" should be printed.
 
Regards
Uday

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
0 votes

You can use below script with selenium javascript executor.

String script = "document.getElementById('log').innerHTML +=" + "your text here";

((JavascriptExecutor) driver).executeScript(script);

 

 

 

by
Thanks Mayur for your answer.

Another method is

String text = driver.findElement(By.cssSelector("div.col-md-8.profile-info")).getText();
   System.out.println(text);

where div.col-md-.profileinfo     is the div of the class containing the paragraph tag.

regards
Uday
by (171 points)
oh okay. I thought you wanted to modify text on webpage. This is to retrieve text
add
...