You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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();
}
}