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