How to get the HTML source of a webpage using Selenium in Java?

0 votes
How can i get the entire page source using selenium webdriver in Java?
Jan 10, 2019 in Selenium by Rishab
• 1,480 points
12,660 views

1 answer to this question.

+1 vote

There is a method called getPageSource() in selenium webdriver.

It returns string, so you can either store it in a file or can print it in the console.

WebDriver driver = new ChromeDriver();
driver.get("https://www.googel.com/");
String str = driver.getPageSource();
System.out.println(str);

Try this.

answered Jan 10, 2019 by Sneha
Any Ideas for Selenium IDE ?
Hey @Mizhar, what exactly is your query though?!

Related Questions In Selenium

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 28, 2018 in Selenium by bug_seeker
• 15,510 points
643 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
3,817 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,801 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,765 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,141 views
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 13,180 points
7,383 views
0 votes
3 answers

How to scroll down a webpage in selenium using Java?

JavascriptExecutor js = ((JavascriptExecutor) driver); js.executeScript("window.scrollTo(0, document.body.scrollHeight)"); or js.executeScript("arguments[0].scrollIntoView(true);", ...READ MORE

answered Sep 3 in Selenium by Sri
• 2,970 points
25,938 views