A, the Instrumentation ( https://developer.android.com/reference/android/app/Instrumentation.html )
1, the Instrumentation principle of what is?
- Automated test applications by directly calling the test class
- And tested in the same application process within
2. What Instrumentation test?
- function test
- Activity life cycle test
- Test simulates the operation of the database
- Compatibility Test
3. What use Instrumentation?
- Use Java Junit Framework
- When the need for white-box testing
- Mock need to use analog technology system objects
Two, UIAutomator ( https://developer.android.com/training/testing/ui-automator )
1, UIAutomator principle of what is?
- Android UI automated testing tools
- You do not need the source code, based on the Java programming language
- UiDevice, UiSelector, UiScrollable, UiObject, UiCollection
2, UIAutomator can test what?
- App UI layer interworking
- Do not need the source code, you can simulate the process of cross-process
- Based on Java JUnit framework, a black box UI Automation
3, how to identify the elements within the App view?
- UiAutomatorViewer(
/tools/bin/) - Identification element may id, classname, bounds, etc.
Three, Selendroid & Robotium
1, Selendroid principle? ( Http://selendroid.io/ )
Selendroid four major components:
- Selendroid Client: WebDriver + achieve mobility characteristics
- Selendroid Server: a Instrumentation APK
- AndroidDriver-App: a WebViewActivity, namely browser
- Selendroid-Standalone: large mains, responsible for preparing the environment
2, Robotium principle? ( Https://github.com/RobotiumTech/robotium )
- Android encapsulated testing framework based Instrumentation, achieved
- Solo encapsulates the library, providing automated testing API
- Because it is based Instrumentation, you need the source code test
Four, Appium ( http://appium.io/ )
1, What is Appium?
- An open source mobile terminal UI Automated Testing Framework
2, Appium idea?
- App does not require source code
- Not limited to the language or framework
- Unified interface, developers do not need to be repeated
- It must be open source
3, Appium related concepts?
- C / S architecture, Appium core is a Web server
- Session, client and server interact to initialize Session
- Desired Capabilities, when initialization key combination
- Appium Server, operating and drive mobile phone
- Appium Client, multi-language support calls
4, Appium environment contain?
- Android SDK、JDK、Appium
- PyCharm, Python environment
- 库: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"