|
|
|
|
package Tools.DataEase;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.openqa.selenium.By;
|
|
|
|
|
import org.openqa.selenium.JavascriptExecutor;
|
|
|
|
|
import org.openqa.selenium.WebDriver;
|
|
|
|
|
import org.openqa.selenium.WebElement;
|
|
|
|
|
import org.openqa.selenium.chrome.ChromeDriver;
|
|
|
|
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
|
|
|
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
|
|
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
|
|
|
|
|
public class TestRead {
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
String url = "http://10.10.14.203/#/de-link/NtXhclS0";
|
|
|
|
|
// 设置ChromeDriver的路径
|
|
|
|
|
//System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
|
|
|
|
|
|
|
|
|
|
// 初始化Chrome浏览器
|
|
|
|
|
WebDriver driver = new FirefoxDriver();
|
|
|
|
|
// 打开目标URL
|
|
|
|
|
driver.get(url);
|
|
|
|
|
// 显式等待,等待页面中特定元素加载完成(例如:等待一个特定的div加载完成)
|
|
|
|
|
//WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(600)); // 10秒超时时间
|
|
|
|
|
//WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("element-id")));
|
|
|
|
|
|
|
|
|
|
// 等待页面加载完成
|
|
|
|
|
new WebDriverWait(driver, Duration.ofSeconds(600)).until(webDriver ->
|
|
|
|
|
((JavascriptExecutor) webDriver).executeScript("return document.readyState").equals("complete")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 获取渲染后的HTML内容
|
|
|
|
|
String renderedHtml = driver.getPageSource();
|
|
|
|
|
// 输出渲染后的HTML内容
|
|
|
|
|
renderedHtml= renderedHtml.replace("./assets","http://10.10.14.203/assets");
|
|
|
|
|
renderedHtml= renderedHtml.replace("./js/","http://10.10.14.203/js/");
|
|
|
|
|
renderedHtml= renderedHtml.replace("./dataease.svg","http://10.10.14.203/dataease.svg");
|
|
|
|
|
|
|
|
|
|
System.out.println(renderedHtml);
|
|
|
|
|
//href="./assets
|
|
|
|
|
// 关闭浏览器
|
|
|
|
|
driver.quit();
|
|
|
|
|
}
|
|
|
|
|
}
|