How to use the common mobile terminal (Android) automated testing tool-Appium

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 ten years. 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 everyone 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

A brief description of Android automated testing The
content of automated testing
Android can be automated through an automated framework or cloud testing platform. The testing 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 automated testing of Android App UI. It uses Java to write test code and is supported by Glide and Android Studio. The test runs quite fast.
  • UI Automator is also a simple UI automation test tool officially released by Google, which can be tested across APPs. It must be used with Android 4.0 or higher. If you want to use the 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, it will also become an appium server, and multiple ports including 4723 are opened by default.
  • Appium-Desktop: In order to make Appium more usable, 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 this tool will become more urgent
Insert picture description here

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

Installation and use of Appium

Apppium installation and configuration (Mac version)
basic environment
setup 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 related environment variables
Install Appium and related packages (Java version)
1 Appium download link .
2 java-client and selenium package download link . Corresponding Java Client, and in the Compile Dependencies at the bottom of its details page, the selenium package that will depend on is also Download it. 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 (the computer and the mobile phone need to be in the same local area network)
// First connect the mobile phone with usb, set the mobile phone tcp connection port to 5555

adb tcpip 5555

// Disconnect the usb and use tcpip to connect to the phone

adb connect 10.33.70.165:5555

// Disconnect tcpip connection

adb disconnect 10.33.70.165:5555

Get App Information

// Get current interface elements

adb shell dumpsys activity top

// Get App entry

adb shell dumpsys activity activities

// start the app

adb shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S

// Get the current interface element 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 are interested in software testing, interface testing, automated testing, and interview experience exchange, you can follow me. We will have technical exchanges with colleagues.

Guess you like

Origin blog.csdn.net/Chaqian/article/details/108402898