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 in Selenium by Rishab
• 1,460 points
131 views

1 answer to this question.

0 votes

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 by Sneha

Related Questions In Selenium

0 votes
2 answers

How to get HTML Source of WebElement in Selenium WebDriver using Python?

You can read innerHTML attribute to get source of ...READ MORE

answered Jun 13, 2018 in Selenium by Samarpit
• 5,130 points
10,924 views
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,310 points
118 views
0 votes
1 answer
0 votes
1 answer

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,050 points
263 views
0 votes
1 answer
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,130 points
629 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
258 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
• 11,490 points
115 views
0 votes
2 answers

How to scroll down a webpage in selenium using Java?

This works... JavascriptExecutor jse = (JavascriptExecutor)driver; j ...READ MORE

answered Apr 3 in Selenium by anonymous
961 views