(iii) Running the appium example py script

Source: Internet
Author: User
Tags appium

The following two steps are required to run the Appium official own sample PY program

======= First step, get the sample app to test and sample script =============================

Download the following library code (appium sample code) to a local directory

Https://github.com/appium/sample-code

After downloading, open the directory structure, including apps and samples, these 2 large modules

    • Apps include: Sample app to be tested;

    • Included in the example are: sample test scripts to support various languages;

650) this.width=650; "src=" Http://note.youdao.com/yws/res/1477/WEBRESOURCE3423ad3e67487d7068e9b16568d8ab24 "alt=" webresource3423ad3e67487d7068e9b16568d8a "/>

    • The example contains sample scripts written in multiple languages:

650) this.width=650; "src=" http://note.youdao.com/yws/res/1480/WEBRESOURCE08088ba1b0f5bc8b0d9cf75837410710 "alt=" webresource08088ba1b0f5bc8b0d9cf75837410 "/>

Then, CD to the following directory

CD Downloads/samplecode-master/sample-code/apps/testapp

Execute the command to compile the sample program:

XCODEBUILD-SDK Iphonesimulator

Show * * BUILD succeeded * * The compilation is successful;--this line creates a command under the TestApp project. Build/release-iphonesimulator/testapp.app directory;

The complete list of compiled apps to be tested is:

/users/wujia/documents/code/appium-samplecode/sample-code/sample-code/apps/testapp/build/ Release-iphonesimulator/testapp.app

/users/wujia/documents/code/appium-samplecode/sample-code/sample-code/apps/testapp/build/ Release-iphonesimulator/testapp.app

======= The second step, configure the environment to run the sample script (sample script is for the sample app )===========

The following describes how to run python Sample script: python/ios_simple.py

SETP1 , prepare python environment (usually Mac computers are installed on Python by default ):

Install Appium Client Library:

Pip Install Appium-python-clientpip Install Pytest

Step2, Open the emulator, for example , iphone4s,ios8.4;

Step3 , Open Appium,

    • To Modify the configuration: iOS Settings in Basic,app Path , fill in the app package address from the build in the first step, such as

/users/wujia/documents/code/appium-samplecode/sample-code/sample-code/apps/testapp/build/ Release-iphonesimulator/testapp.app

    • To Modify the configuration: General Settings,server Address 127.0.0.1, Port 4723;  

Note that the ServerHost is set to local IP, and the port number needs to be consistent with the ios_simple.py script;

650) this.width=650; "src=" http://note.youdao.com/yws/res/1524/WEBRESOURCE07fc58b1ce33f620843d7b162565ac3a "alt=" webresource07fc58b1ce33f620843d7b162565a "/>

Make sure the app address in the script is the app package address to be tested;

Ensure that the ServerHost in the script is consistent with the port and the Appium configuration;

Ensure that the devices in the script is consistent with the launched emulator;

After the above are confirmed configured, start Appium server, click Launch, start success;

Step4, open terminal, CD to ios_simple.py The script is located at the directory where the execution begins

Py.test ios_simple.py

At this point, the emulator will automatically restart the testAPP program, according to the Py script logic, execute 2 testcase,

Run the process as shown

650) this.width=650; "src=" Http://note.youdao.com/yws/res/1535/WEBRESOURCE450b61eec2a2866a2165b20ac24226e4 "alt=" webresource450b61eec2a2866a2165b20ac2422 "/>

running results, e.g., 1 x Test Pass , 1 x Test fail

650) this.width=650; "src=" http://note.youdao.com/yws/res/1537/WEBRESOURCE1cc2dda1eba0f01a5efcebd691d9a148 "alt=" webresource1cc2dda1eba0f01a5efcebd691d9a "/>

Run the end, check the error go ~

Summarize:

1. When configuring Appium server, you need to configure the. App package address for the app you want to test so that Appium calls instruments to automatically install and launch the app you want to test;

2. Test the corresponding Appium server and port in the Py script to be consistent with the Appium configuration, otherwise it will not connect to the server;

With environment installation small help:

Pip is a tool for installing the Python package, providing an installation package that lists the packages that have been installed, the upgrade package, and the ability to uninstall the package;

Install PIP: sudo easy_install pip


(iii) Run the Appium sample py script

Related Article

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.