0
我發現Selenium 2現在支持WebDriverEventListener,但事件似乎並不是瀏覽器DOM的事件。有沒有辦法在我的Java測試框架內檢測DOMContentLoaded?從Selenium/Webdriver檢測DOMContentLoaded
我發現Selenium 2現在支持WebDriverEventListener,但事件似乎並不是瀏覽器DOM的事件。有沒有辦法在我的Java測試框架內檢測DOMContentLoaded?從Selenium/Webdriver檢測DOMContentLoaded
事實證明,你可以使用新的Web API時序:
System.setProperty("webdriver.chrome.driver","/home/joel/dev/libs/chrome-web-driver/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
JavascriptExecutor js =((JavascriptExecutor) driver);
Object val = js.executeScript("" +
"try{window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};" +
"return(parseInt(window.performance.timing.domContentLoadedEventEnd)-parseInt(window.performance.timing.navigationStart));}catch(e){alert(e);}");
System.out.println(val.toString());