Python special test--android app Automation testing Framework

Source: Internet
Author: User
Tags appium

1 Why do I need frames?

Code confusion, difficult to read, repetitive coding, low efficiency, changes in demand, difficult to maintain;

An example of automation

1 Prepare the test app, prepare the test environment, implement the script;

2 Test app: only login function

Test environment:

    • Appium (Android/ios);
    • Android SDK;
    • Appium-python-client;
    • Selenium (appium-python-client inherited from Selenium);
    • Uiautomatorviewer
    • Pycharm

3 Implementing the Script

writing scripts in Pycharm;

Using Uiautomatorviewer to locate;

APIs implemented with Appium-python-client;

implement attributes with Appium-python-client's dictionary;

To start Appium and set it before running the script, release the resource and restart Appium if a "new session cannot be established" error occurs .

Two test framework UnitTest

1 Main explanation: Test Fixture;  Test case; Test Suite; Test Runner

2 Test fixture includes preparation, execution, and cleanup of the process; corresponding to the script is: Setup (), testcase (), teardown ()

Three other items are known.

3 scripts

Three-data-driven framework

1 How do I use it? Prepare a third-party library-first install the DDT library, followed by the introduction of DDT in the script, then OK

Specific:

  • Download the DDT library on the Python website;
  • Commands for importing DDT libraries in scripts: From DDT import DDT, data, unpack
  • To label DDT before testing the class: @ddt
  • strong>                               class Mooktestcase (unittest. TestCase), indicating that this test class is using the data-driven framework
  • Test cases are mainly divided into parameters and no parameters, data driven mainly for test cases with parameters
  • For use cases with one parameter, use tuples to store the data being tested, and add it with data annotations: @data (1,-3, 2, 0)
  • Def testcase (self, value):
  • For use cases with multiple parameters, use tuples to store the data that is being tested, and add the date callout: @data ((3,2), (4,3), (5,3))
  • @unpack
  • Def testcase (self, value1, value2):

2 Application in Scripts

3 when the DDT framework is applied, statements that run a single case are no longer applicable, but can be loaded to run the entire test class.

Python special test--android app Automation testing Framework

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.