app自动化8-android自动化

1. Native原生应用分类:

    1> Android标准组件;

    2> 非标准组件:

          a> Flutter:闲鱼

          b> Reatc Native:Facebook

          c> Weex:极客时间

    3> 游戏

2. Hybrid混合App自动化测试:webvie控件在Appium中的抽象

    1> Native层面支持:

         a> uiautomator 解析 webview中的内容并映射为原生控件

         b> getPageSource为DOM结构可发现webview组件和控制

    2> 切换为webview上下文

         a> 切换后才是正规的web

         b> getPageSource为HTML

         c> 可以使用CSS定位等

3. Hybrid测试流程:

    1> 首先进去带有webview的页面

    2> 使用Contexts API寻找WebView

    3> 使用Context切换到WebView

    4> 使用CSS等web定位方式

    5> 使用Context重回Native

4. webview自动化测试前提,在应用中启用webview调试,在webview类上调用静态方法setWebContentsDebuggingEnabled

5.   1> 在谷歌浏览器输入:chrome://inspect/#devices (需要FQ)

    ps:获取手机webview的版本命令: adb shell am start -a android.intent.action.VIEW -d https://liulanmi.com/labs/core.html

6. webview自动化常见问题:

    1> chromedriver not found

 

     2> chrome version must be >=

     3> chrome not reachable  (安卓8.0的一个bug)

7. chromedriver与chrome版本对应关系和下载,查看连接:

       1> https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md

 

 PS:国内镜像文件下载连接: https://npm.taobao.org/mirrors/chromedriver?spm=a2c6h.14029880.0.0.735975d75C1lH1

      2> 下载对应的chromedriver版本,配置方法:

           a> 通过Capabilities参数配置

             http://appium.io/docs/en/writing-running-appium/caps/

     b> 调试开关:showChromedriverLog

 

 

8. android webview进程信息:

   1> getContextHandles   

       a> 查看所有的webview进程:adb shell cat /proc/net/unix | grep webview

   2> Context 切换

        a> 把domain socket映射为本地的socket端口

        b> adb forward tcp:$port localabstract:webview_devtools_remote_$pid

        c> 获取对应的webview组件版本:http://localhost:$port/json/version

   3> chromedrvier协议交互

9. 纯H5自动化测试 29节还没有完成记录

   1> 构架结构:

 

 

    2> 

posted @ 2020-08-12 11:03  宁静~朝夕  阅读(13)  评论(0编辑  收藏  举报