Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
245 views
in Selenium by
<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

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)

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 The go-to Tester (181 points)
oh okay. I thought you wanted to modify text on webpage. This is to retrieve text


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...