I am searching for a way to get the POST html code of a webpage that is rendered. In Firefox there is an AddOn called Web Developper which can return not only the "normal" sourcecode but also the rendered sourcecode.
Example: https://bs.chregister.ch/cr-portal/auszug/auszug.xhtml?uid=CHE-230.467.384#
I need to get an HTML sourcecode of this website that includes content like the adress (in this case "c/o Nora Stähelin" and "Kraftstr. 1"). My code looks like this:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Automation {
public static void main(String[] args) {
String exePath = "src\\seleniumAutomation\\resources\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", exePath);
WebDriver driver = new ChromeDriver();
String URL = "https://bs.chregister.ch/cr-portal/auszug/auszug.xhtml?uid=CHE-230.467.384#";
driver.get(URL);
// get PRE SourceCode
String pageSource = driver.getPageSource();
System.out.println(pageSource);
// get POST SourceCode (containing content)
// TODO
// close window
driver.quit();
}
}
edit: generated HTML refers to the HTML after JavaScript changes the DOM.