Hi i want to take screenshot on the view page source to verify the Release details, is there any possibility of taking the screenshot on page source or i need to get the text from the particular line as like we access element in the webpage...please let me know as soon as possible. Thanks in advance
Asked
Active
Viewed 160 times
1 Answers
0
The screenshot function will create an image (PNG or JPEG) of the rendered web page.
To get the source code, you need to execute this JavaScript in the context of the page:
return document.innerHTML;
like so:
JavascriptExecutor js = (JavascriptExecutor) driver;
String dump = js.executeScript("return document.innerHTML;");
That will return the current DOM as a string. Use a HTML parsing library or regexp to analyze it.
If the element in question has an ID or class, you can use the methods document.getElementBy...()
to find it.

Aaron Digulla
- 321,842
- 108
- 597
- 820