【发布时间】:2015-06-20 05:27:44
【问题描述】:
如何使用 Selenium JavaScriptExecutor 获取 HTML5 Cache 状态?
我尝试如下,但没有得到正确的状态。
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.html5.AppCacheStatus;
import org.openqa.selenium.html5.ApplicationCache;
public class Html5AppCache {
public void testHTML5LocalStorage() throws Exception {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.w3schools.com/html/tryhtml5_html_manifest.htm");
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
String cacheStatus = (String) jsExecutor.executeScript("return window.applicationCache.status;");
}
}
【问题讨论】:
标签: java javascript html selenium