Answer the question
In order to leave comments, you need to log in
How to save http page in selenium java pc?
Good afternoon. I'm trying to save an HTTP page to my computer using WebDriver driver = new FirefoxDriver(); using the hot keys CTRL + S; here is the code i use
System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to(" https://www.google.com ");
TimeUnit.SECONDS.sleep(5);
Actions a = new Actions(driver);
a.keyDown(Keys.CONTROL).perform();
a.sendKeys("S").perform();
a.keyUp(Keys.CONTROL).perform();
a.sendKeys(Keys.ENTER).perform();
driver.close();
but nothing happens and the build completes successfully. what am I doing wrong?
Answer the question
In order to leave comments, you need to log in
Good afternoon.
How to save http page in selenium java pc?
public void downloadPage() throws Exception {
final Response response = Jsoup.connect("http://www.example.net").execute();
final Document doc = response.parse();
final File f = new File("filename.html");
FileUtils.writeStringToFile(f, doc.outerHtml(), StandardCharsets.UTF_8);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question