Python and Nose realize automatic test of mobile application

Today I'm talking with you about Python and Nose's automatic testing of mobile applications. I hope it can help you. There's something bad to say. Please give me more advice!

The coolest thing about automated functional testing with Appium is that you can write your test code in any language that has the best testing tools for you. Python is the most widely chosen test programming language. It's easy to write test code for iOS and Android applications using Appium and python.

In this blog, we will explain in detail the steps involved in testing an iOS sample application with the test code written in Python under Appium, and the steps required for testing an Android application are very similar to this.

First, start from and clone Appium, then follow the installation guide to install Appium on your machine.

I also need to install all the dependencies of Appium and compile the sample apps. Run the following command in Appium's working directory to complete this task:

$ ./ --ios

After compiling, you can run the following command to start Appium:

$ grunt appium

Now that Appium is running, switch the current directory to sample code / examples / python. Then use the pip command to install all the dependent libraries (if not under the virtualenv, you need to use the sudo command):

$ pip install -r requirements.txt

Next, run the sample test:

$ nosetests

If for software testing, interface testing, automation testing, interview experience exchange. If you are interested, you can add software test exchange: 1085991341, and there will be technical exchanges with peers.

Now that you have installed the required software and run the test code, and have a general understanding of Appium's work process, let's take a closer look at the sample test code that just ran. This test starts the sample application, fills in some contents in several input boxes, and finally compares the running results with the expected results. First, we created the test class and its setUp method:













'app': app



The "desired capabilities" parameter is used to specify the running platform (iOS 6.0) and the application we want to test. Next, we add a tearDown method and send the exit command after each test:



Finally, we define the auxiliary method and the main test method to fill in the form


# populate text fields with two random number







# populate text fields with values


# trigger computation by using the button



# is sum equal ?



That's it! There are many Python examples in Appium's sample test code. If you have any questions or comments on using Nose and python to run Appium tests, please let me know. I hope the above content can help you. If you have any friends who have been helped, please comment

Keywords: Programming Python iOS Android pip

Added by sottwell on Wed, 06 May 2020 15:13:20 +0300