我想使用 java webdriver selenium 在https://appleid.apple.com/中自动执行身份验证过程,但表单的 html 元素未加载到 DOM 中
据我所知,Selenium webdriver 像浏览器一样解释标记。它应用 CSS 样式,运行 JavaScript 并将动态呈现的内容添加到 DOM
为什么 HTML 元素没有加载到 DOM 中?
我该如何继续,修复它并加载 DOM 中的所有元素,就像浏览器一样?
注意:https ://appleid.apple.com/网站使用 Mustache.JS(无逻辑模板)
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--disable-gpu", "--window-size=1920,1200", "--ignore-certificate-errors");
WebDriver driver = new ChromeDriver(options);
driver.get("https://appleid.apple.com/");
waitForPageLoadComplete(driver, 30);
//can't found input name element
WebElement inputName = driver.findElement(By.id("account_name_text_field"));
System.out.println(driver.getPageSource());
}
慕斯709654
相关分类