The article understands how to use the common mobile terminal (Android) automated testing tool-Appium

automated test

Everyone knows about automated testing. In the past ten years, the skill of automated testing has always been a skill that software testing practitioners want to master. According to relevant surveys, about seven people want to master automated testing skills in the past decade. to make

Insert picture description here

This article will bring the content of mobile terminal (Android) automated testing in automated testing and a brief overview of its testing framework, hoping to give you a general understanding of Android automated testing, and then take Appium as an example to introduce its environment Construction and basic use.

Android automated testing

Android automated testing brief description of automated testing content Android can be automated testing through the automation framework or cloud testing platform, the test content includes the following aspects

  • Compatibility test: install, start, uninstall
  • Function test: gesture operation, function verification
  • Stability test: Is the app prone to crashes and other phenomena
  • Scene test: simulate real network scene, switch between 2G, 3G, 4G, wifi network

Automated testing framework

  • Espresso Espresso is Google's open source Android automated testing framework for the Android platform. It is mainly used for Android App UI automated testing. The test code is written in Java, supported by Glide and Android Studio, and the test runs quite fast.
  • UI Automator is also a simple UI automation test tool officially released by Google. It can be tested across APPs. It must be used with Android 4.0 or higher. If you want to use resource id to locate the control when positioning, it must be above API18. uiautomatorviewer is a tool that comes with the android SDK. By taking screenshots and analyzing XML layout files, it provides users with control information viewing services. The tool is located in the tools\bin subdirectory of the SDK directory
  • Appium Appium is an open source, cross-platform testing framework that can be used to test Native App, hybrid applications, mobile web applications (H5 applications), etc. Appium: It is the core of the Appium system, because it is also a web interface service, so It will become an appium server, and multiple ports including 4723 are opened by default. Appium-Desktop: To make Appium easier to use, make it easier for Xiaobai to get started, and make debugging and interface analysis more convenient, the official GUI tool Appium-desktop has been developed. Appium Client: Appium is just a web interface, it accepts HTTP requests, so each language can encapsulate and send the request by itself, so there are various sub-projects under appium.

Among the above three frameworks, Appium is the most common one. Especially in recent years, Appium's market share has increased from 25% to 42% in 19 years. Without major technological breakthroughs, Appium will have a bigger future. Market share, learning Appium as a tool will become more urgent

Insert picture description here

Next, I will teach you how to install and use Appium.

Appium installation and use
Apppium installation and configuration (Mac version) Basic environment construction

1 Install java environment , git, ruby, brew, Android SDK environment
// Check if the above environment is installed
java -version
git --version
ruby -v
brew -v
adb

2 Configure the relevant environment variables to install Appium and related packages (Java version) 1 Appium download 2 java-client and selenium package download Select the corresponding Java Client, and download the dependent selenium package under Compile Dependencies at the bottom of its details page. When writing Java automated test scripts, download packages in Compile Dependencies, such as commons-lang3, as needed.

Insert picture description here
Insert picture description here

Basic use of Apppium

Insert picture description here

adb command

Use tcpip to connect to the mobile phone (needs the computer and mobile phone to be in the same LAN)

// 先usb连接手机,设置手机tcp连接端口为5555
adb tcpip 5555
// 断开usb,采用tcpip连接手机
adb connect 10.33.70.165:5555
// 断开tcpip连接
adb disconnect 10.33.70.165:5555

Get App Information

// 获取当前界面元素
adb shell dumpsys activity top
// 获取App入口
adb shell dumpsys activity activities
// 启动app
adb shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S
// 获取当前界面元素 adb shell dumpsys activity top

Operate the phone (input, key press, click, slide)

adb shell text/keyevent/tapswipe/press/roll

Conclusion

The above content is the entire content of this article. The above content hopes to be helpful to you. Friends who have been helped are welcome to like and comment. If you want to exchange experience in software testing, interface testing, automated testing, and interviews. If you are interested, you can join the group 313782132, and we will have technical exchanges with colleagues.

Software testing is the easiest subject in IT-related industries to get started~ It does not require the logical thinking of developers, and operations and maintenance personnel are not required to be on call 24 hours a day. What is needed is a careful attitude and a broad understanding of IT-related knowledge. The growth path of each tester from entering the industry to becoming a professional expert can be divided into three stages: software testing, automated testing, and test development engineers.

Insert picture description here

Here are some information I have compiled. If you don’t want to experience the self-study again, you can’t find the information, no one answers the question, and you feel like giving up after a few days, you can add our software testing exchange group 313782132, which contains various software Test data and technical exchange

Guess you like

Origin blog.csdn.net/weixin_50271247/article/details/109309849