3 回答
TA贡献1911条经验 获得超7个赞
@ supputuri的回答是工作和接受的答案作为定位战略,通过document.querySelector()工程,经过完善的谷歌,铬devtools
然而,由于所需的元素从打开阴影DOM需要引起WebDriverWait的elementToBeClickable(),你可以在你的解决方案如下:
代码块:
driver.get("chrome://settings/clearBrowserData");
new WebDriverWait(driver, 5).until(ExpectedConditions.elementToBeClickable((WebElement) ((JavascriptExecutor)driver).executeScript("return document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings-section > settings-privacy-page').shadowRoot.querySelector('settings-clear-browsing-data-dialog').shadowRoot.querySelector('#clearBrowsingDataDialog').querySelector('#clearBrowsingDataConfirm')"))).click();
System.out.println("Clear data Button Clicked");
控制台输出:
Clear data Button Clicked
添加回答
举报