Appium automated testing framework construction

Source: Internet
Author: User
Tags appium

Appium Introduction

Appium is an open-source, cross-platform testing framework that can be used to test native and hybrid mobile applications. Appium supports testing on iOS, Android, and FirefoxOS. Appium uses the json wire protocol of WebDriver to drive the UIAutomation library of Apple and the UIAutomation framework of Android.

Compared with other mobile automated testing tools, Appium testing calls the Selenium client library so that it can use any language, including Python, Ruby, Node. js, and Objective-C.

You can download and install Appium from the official website or github. The latest version is 0.17.6. Of course, there are also network disks in China, so you don't need fan. qiang. It is convenient to download and decompress the package. The current Appium version requires. net4.5 and later support. Therefore, to use Appium, you still need to install. net4.5.1. You can download. net4.5.1 from Microsoft. Of course, it is also available on the network disk. Because Appium uses Selenium for automated testing, Selenium needs to be installed, and Selenium can be downloaded from the network disk. Download the package, decompress the package, switch to the decompressed directory, and run python setup. py install to install Selenium. If you are familiar with pip, install Selenium with pip. To install and configure the Android simulator, we plan to use appium for automated testing on the simulator. Therefore, we must first download and install the android development environment, after the IDE development environment is configured, you can create an android mobile phone simulator through eclipse. Download JDK and configure JDK download JDK, double-click the package and install it. By default, jdk is installed in the C: \ Java directory, there are two folders: jdk1.6.0 _ 13 and jre6. It is easy to configure jdk to add the C: \ Java \ jdk1.6.0 _ 13 \ bin directory to the path of the system environment variable, remember the plus points, and then confirm. How to test whether java is configured? After cmd, enter java-verison to download the android Development Environment ADT-bundle. You can download it from Google or from the online storage to download the android integrated development environment. Download the package and decompress it to the c: \ android directory. Configure ADT to add the tools and platform-tools directories under the decompressed directory to the path of the system environment variable, remember the plus points, and then confirm. How can I test whether the ADT of android is configured? Log on to c: \ android \ eclipsedirectory and double-click eclipse.exe to check whether it can be started and used properly.
Start eclipse on the new AVD simulator, click the Windows menu of Eclipse software, select the Android Virtual Device Manager menu under it, and enter the Android Virtual Device Manager dialog box, click the New button on the left to create an android phone simulator. In the name text box of the Create new Android Virtual Device Manager dialog box, name the simulator to be created, for example, testAVD01. In the Device list box, select 2.7 QVGA 240X320 ldpi. After Device is selected, the target list box automatically selects android 4.4 API Level 19 {currently, only one set of APIS is available in the installed development environment, you can install other APIs on your own. You can select other APIs as your testing platform} by default. If you do not select the default settings for other options, click OK in the dialog box, you can create an Android simulator.
Start the android simulator cmd and type emulator @ testAVD01. wait a few seconds before the android phone simulator starts. Installing and configuring Python is simple. Download Python and install it by default. After adding the c: \ python27 directory to the path of the system environment variable, remember the first plus points. Run cmd and type python. If you see three signs, the python installation and configuration are successful. After the Appium automated testing process starts the android mobile phone simulator cmd, type emulator @ testAVD01. wait a few seconds before the android mobile phone simulator starts. Run another cmd and type adb devices to check whether the simulator is started properly. Start appiumto enter the appiumdecompression directory, double-click the appium.exe file, and click launch. Write code for Appium-based Python Automated Testing
From selenium import webdriver # Returns abs path relative to this file and not cwdPATH = lambda p: OS. path. abspath (OS. path. join (OS. path. dirname (_ file _), p )) desired_caps = {} desired_caps ['devic'] = 'android' desired _ caps ['browsername'] = ''inclured _ caps ['version'] = '4. 2 'inclured _ caps ['app-package'] = 'com. android. calculator2 'inclured _ caps ['app-activity'] = '. calculator 'driver = webdriver. remote ('HTTP: // localhost: 4723/wd/hub ', desired_caps) # click the number and operator el = driver on the calculator. find_element_by_name ("1") el. click () el = driver. find_element_by_name ("5") el. click () el = driver. find_element_by_name ("9") el. click () el = driver. find_element_by_name ("delete") el. click () el = driver. find_element_by_name ("9") el. click () el = driver. find_element_by_name ("5") el. click () el = driver. find_element_by_name ("+") el. click () el = driver. find_element_by_name ("6") el. click () el = driver. find_element_by_name ("=") el. click () driver. quit ()


Run the command cmd and switch to the directory where the python code is located. Run python xxx. py to see that the simulator is being operated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.