As @browsermator answered putting sleep before get works.
package com.tugalsan.tst.html;
import static java.lang.System.out;
import java.nio.file.Path;
import java.time.Duration;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
public class Main {
public static void main(String... args) throws InterruptedException {
var urlPath = Path.of("C:\\git\\tst\\com.tugalsan.tst.html\\a.html");
var urlStr = urlPath.toUri().toString();
var until = Duration.ofSeconds(15);
var scrnSize = new Dimension(640, 480);
var output = processHTML(urlStr, until, scrnSize);
out.println(output);
}
public static String processHTML(String urlStr, Duration until, Dimension scrnSize) throws InterruptedException {
WebDriver driver = null;
try {
var options = new EdgeOptions();
driver = new EdgeDriver(options);
driver.manage().timeouts().implicitlyWait(until);
driver.manage().timeouts().pageLoadTimeout(until);
driver.manage().window().setSize(scrnSize);
driver.get(urlStr);
Thread.sleep(until);
return driver.getPageSource();
} finally {
if (driver != null) {
driver.close();
}
if (driver != null) {
driver.quit();
}
}
}
}