zoukankan      html  css  js  c++  java
  • [Selenium] Android HTML5 中 Application Cache

    HTML5 中引入了 Application Cache,这意味着 Web 应用程序可以被缓存到本地,且可在没有网络的情况下也能访问该 Web 应用程序

    Application Cache 在以下3个方面具有明显优势

    1.离线浏览:在没有网络情况下用户也可使用 Web 应用程序

    2.速度快:缓存的资源被加载时速度很快

    3.服务器负载小:浏览器只会从服务器更新有变化或新增的资源

    确认 Web 应用程序是否使用了改缓存特性的最简单方式就是直接查看网页 HTML 代码,如果其源码中具有如下包括 manifest  属性的标签则说明使用了 Application Cache 特性

    <! DOCTYPE HTML>

    <html manifest="demo.appcache">

    ...

    </html>

    Selenium WebDriver 具有一个名为 AppCacheStatus 的枚举量,用于标记当前 Application Cache的状态,包括 0(UNCACHED)、1(IDLE)、2(CHECKING)、3(DOWNLOADING)、4(UPDATEREADY)、5(OBSOLETE)

    下面以获取当前 Web 应用程序的缓存状态为例 展示对 Application Cache 的接口如何使用

    package com.learingselenium.android;

    import static org.junit.Assert.assertEquals;

    import org.junit.Test;

    import org.openqa.selenium.WebDrivver;

    import org.openqa.selenium.android.AndroidDriver;

    import org.openqa.selenium.html5.AppCacheStatus;

    import org.openqa.selenium.html5.ApplicationCache;

    ...

    WebDriver driver = new AndroidDriver("http://localhost:8888/wd/hub");

    driver.get("http://w3school.com/html/tryhtml5_html_manifest.htm");

    AppCacheStatus status = ((ApplicationCache) driver).getStatus();

    assertEquals(status, AppcacheStatus.DOWNLOADING);

    System.out.println("Application Cache's status is : " + status.toString());

    driver.quit();

    ...

  • 相关阅读:
    实验楼挑战赛(1)-实现不可修改字典
    python django前端界面实现数据库数据excel导出
    python2中range和xrange的异同
    python的json模块的dumps,loads,dump,load方法介绍
    ajax500错误
    伪元素小tips
    使用css3制作蚂蚁线
    chardet坑——比蜗牛还慢
    Flask的socket.error:10053
    chrome插件开发-消息机制中的bug与解决方案
  • 原文地址:https://www.cnblogs.com/feifeidxl/p/4561088.html
Copyright © 2011-2022 走看看