• 测开面试 | 自动化测试之工具篇


    一、Instrumentation(https://developer.android.com/reference/android/app/Instrumentation.html)
    1、 Instrumentation 原理是什么?

    • 通过直接调用被测应用的类实现自动化测试
    • 和被测应用处于同一个进程内

    2、 Instrumentation 测试什么?

    • 功能测试
    • Activity 生命周期的测试
    • 模拟数据库操作的测试
    • 兼容性测试

    3、 什么情况使用 Instrumentation?

    • 使用 Java Junit 框架
    • 需要进行白盒测试时
    • 需要使用 Mock 技术模拟系统对象时

    二、UIAutomator(https://developer.android.com/training/testing/ui-automator)
    1、 UIAutomator 原理是什么?

    • Android UI 自动化测试工具
    • 不需要源码,基于 Java 开发语言
    • UiDevice, UiSelector, UiScrollable, UiObject, UiCollection

    2、 UIAutomator 可以测试什么?

    • App UI 层的交互操作
    • 不需要源码,可以模拟跨进程过程
    • 基于 Java JUnit 框架,黑盒 UI 自动化

    3、 如何识别 App 视图内的元素?

    • UiAutomatorViewer(<Android_SDK>/tools/bin/)
    • 可以识别元素的 id、classname、bounds 等

    三、Selendroid&Robotium
    1、 Selendroid 的原理?(http://selendroid.io/)
    Selendroid 四大组件:

    • Selendroid Client: WebDriver + 移动特性的实现
    • Selendroid Server: 一个 Instrumentation APK
    • AndroidDriver-App: 一个 WebViewActivity,即浏览器
    • Selendroid-Standalone: 大总管,负责准备环境

    2、 Robotium 的原理?(https://github.com/RobotiumTech/robotium)

    • 基于 Instrumentation 进行封装,实现的 Android 测试框架
    • 封装了 Solo 类库,提供自动化测试 API
    • 由于是基于 Instrumentation,测试时需要源码

    四、Appium(http://appium.io/)
    1、 什么是 Appium?

    • 一个开源的移动端 UI 自动化测试框架

    2、 Appium 的理念?

    • 不需要 App 源码
    • 不局限于语言或者框架
    • 接口统一,不需要重复开发
    • 必须是开源的

    3、 Appium 相关的概念?

    • C/S 架构,Appium 核心是一个 Web 服务器
    • Session,客户端初始化 Session 与服务端交互
    • Desired Capabilities,初始化时的键值对组合
    • Appium Server,操作与驱动手机
    • Appium Client,支持多语言调用

    4、 Appium 环境包含哪些内容?

    • Android SDK、JDK、Appium
    • PyCharm、Python 环境
    • 库:Selenium、Appium-Python-Client

    5、 Appium 支持哪些开发语言?

    • Java、Javascript、PHP、Python、Ruby、Perl、C#、Object-C

    6、 Appium 初始化时需要配置哪些内容?

    • platformName,目标设备平台(Android/iOS)
    • platformVersion,目标设备平台版本
    • deviceName,目标设备名称
    • appPackage,应用包名(Android)
    • appActivity,应用活动名(Android)
    • automationName,自动化驱动类型(Selendroid/Appium)
    • unicodeKeyboard,是否使用 Appium 输入法
    • resetKeyboard,是否恢复默认键盘

    7、 Appium 测试 Native App 的原理?

    8、 Appium 测试 Hybrid App 的原理?

    9、 Appium 测试 iOS App 的原理?

    五、如何自动化测试 Native App?
    1、 元素的定位、识别工具?

    • 第一个选择:UIAutomatorViewer
    • 第二个选择:Appium 的 Inspector

    2、 定位元素的 API 都有哪些?

    • find_element_by_accessibility_id
    • find_element_by_id
    • find_element_by_name
    • find_element_by_xpath
    • find_element_by_class_name
    • find_elements_by_accessibility_id
    • find_elements_by_id
    • find_elements_by_name
    • find_elements_by_xpath
    • find_elements_by_class_name

    3、 脚本的编写规则
    LOVE 规则:

    • L:Locate 定位
    • O:Operate 操作
    • V:Verify 验证
    • E:Exception 异常的处理

    4、 初始化注意事项

    • 1、 不需要指定 App 的包路径
    • 2、 默认使用 Appium 驱动
    • 3、 如果需要输入中文,需要添加输入法相关的配置

    六、如何自动化测试 Hybrid App?
    1、 元素的定位、识别工具?

    • 1、 Native 部分,UIAutomatorViewer 或者 Appium Inspector
    • 2、 WebView 部分,Chrome 浏览器的调试模式

    2、 定位元素的 API 都有哪些?

    • find_element_by_id(HTML 页面中的 ID)
    • find_element_by_name
    • find_element_by_xpath
    • find_element_by_link_text
    • find_element_by_tag_name
    • find_element_by_class_name
    • find_elements_by_id
    • find_elements_by_name
    • find_elements_by_xpath
    • find_elements_by_link_text
    • find_elements_by_tag_name
    • find_elements_by_class_name

    3、 脚本的编写规则
    S-LOVE 规则

    • S:Switch 在 Native 和 WebView 之间切换
    • L:Locate 定位
    • O:Operate 操作
    • V:Verify 验证
    • E:Exception 异常的处理

    4、 初始化注意事项

    • 需要明确指定驱动名称为:Selendroid
    • 需要明确指定 App 的路径(重签名用)

    七、如何使用 Selenium 测试 WEB 页面?(https://www.seleniumhq.org/)
    1、 环境的准备

    • 工具:Pycharm、Chrome
    • 包:Selenium、Python
    • WebDriver:Chrome Driver/Firefox Driver/IE Driver 等

    2、 元素识别工具是什么?

    • Firefox 或者 Chrome 的调试工具

    3、 元素定位的方法?

    • find_element_by_id(HTML 页面中的 ID)
    • find_element_by_name
    • find_element_by_xpath
    • find_element_by_link_text
    • find_element_by_tag_name
    • find_element_by_class_name
    • find_elements_by_id
    • find_elements_by_name
    • find_elements_by_xpath
    • find_elements_by_link_text
    • find_elements_by_tag_name
    • find_elements_by_class_name

    八、如何使用 Appium 测试 WAP 页面?
    1、 环境的准备

    • IDE:PyCharm
    • 包:Python、Selenium、Appium-Python-Client
    • 工具:Appium、Chrome

    2、 元素的识别

    • Chrome 浏览器调试 WAP 页面

    3、 脚本的编写

    • 初始化时,指定 browsername 为:Browser
    • 自动化测试代码和 Selenium 相同

    欢迎关注微信公众号"测试开发Stack"

  • 相关阅读:
    luoguP1919 A*B Problem升级版 ntt
    luogu[愚人节题目3]现代妖怪殖民地 NTT
    FFT 快速傅里叶变换 学习笔记
    十二省联考 爆0记
    # NOI.AC省选赛 第五场T1 子集,与&最大值
    2019.6.16完成classstack任务
    USACO-集合
    USACO-修理牛棚
    dij模板
    洛谷P1948 [USACO08JAN]电话线Telephone Lines
  • 原文地址:https://www.cnblogs.com/liushengchieh/p/10936453.html
Copyright © 2020-2023  润新知