A 2500-word article from 0 to 1 teaches you to build an Android automation python+appium environment

1. Need software

1. JDK: Configure JDK environment after JAVA installation

2. SDK: Configure the adb environment after downloading the SDK

3. Python: pyhton language

4. Pycharm: python script compilation tool

5. Appium-python-client: library in pyhton

6. Appium client

2. Construction steps

1. Configure the JDK environment

①. Download and install java:

https://www.oracle.com/java/technologies/javase-jdk14-downloads.html

②. When installing, you need to pay attention to the fact that java and jre are installed in two separate directories. Otherwise, problems will occur

③. Configuration environment:

Right-click on the computer-->Properties-->Advanced System Settings->Environment Variables:

Enter the java and jre directories in the system variables: You can also refer to Baidu to solve configuration problems

2. Configure the SDK environment:

①. Download the SDK:

https://android-sdk.en.softonic.com/

②.Configuration

After the SDK is downloaded, there is no need to install it, just unzip the configuration.

Enter the platform-tools and tools directories in the system variable ->path, and Baidu can also solve it.

3. Download and install python

①. Download: Download the corresponding system version

https://www.python.org/

②. Installation, you need to pay attention to check add pyhton to path during installation, so that the environment variables can be automatically configured

③. Enter pyhton in CMD and press Enter to display the pyhton version, indicating that the installation and configuration are successful

4. Download and install Pycharm

①. Download: https://www.jetbrains.com/pycharm/

②. When installing, you need to pay attention to check the appropriate shortcut, there are 32-bit and 64-bit, choose according to your own system

③. When opening a new project in pycharm, you must configure the interpreter. You can configure it when you create a new project, or you can configure it in file-->settings

④. After configuration, it can be opened for programming

5. Install the Appium-python-client library

This can be divided into two methods:

①. Install in cmd: enter cmd, enter pip install Appium-python-client, wait for the installation to complete

②. Select project interpreter in file-->settings-->project in pycharm, click on + in the upper right corner of the package list, then search for Appium-python-client, click install package at the bottom of the window, and wait for the installation to complete

6. Appium client:

①. Download: http://appium.io/

②. Generally, the default installation is enough

3. Mobile phone configuration

1. Turn on developer mode

2. Enable USB debugging mode

3. In CMD, enter adb devices to identify the mobile phone information, indicating success

4. Open the uiautomator.bat file in SDK->tools, and you can locate the elements on the phone

4. Code implementation

1. Open pycharm

2. The installed library needs to be imported before it can be used: from appium import webdriver

3. Then configure the device information:

desired_caps={ #Mobile device platform 'platformName':'Android', #Platform OS version number'plathformVersion':'7', #The name of the device -- the value can be written casually 'deviceName':'test0106', #Provide the tested App information-package name, entry information'appPackage':'com.hpbr.bosszhipin', 'appActivity':'.module.launcher.WelcomeActivity', #Ensure that the app is not reset after automation 'noReset':True, #Set Session timeout, in seconds 'newCommandTimeout': 6000

4. Initialize the object:

#Initialize driver object - used to control mobile phone driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)driver.implicitly_wait(10)#Stable elements

5. In the next step, element positioning can be performed

The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

Information acquisition method:

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/132105123