Problem: Maintaining infrastructure for testing your mobile applications on different platforms and browser versions is time consuming.
Why this post?
This post was written for the hands on tester looking to explore different tools testers can use for mobile automation. In this post we will show you how to run your Appium tests on Sauce Labs. We estimate that you need about one hour to try this post on your own. We will start with the test we wrote in a previous post, titled GET STARTED WITH MOBILE AUTOMATION: APPIUM & PYTHON, and modify the test script so it runs on Sauce Labs.
NOTE: Sauce Labs offers a limited free plan for individuals. I recommend that testers take them up on the deal use it to get started. Knowing an extra tool is always useful.
Getting started with Appium on Sauce Labs
1. Sign up for a Sauce Labs Account
2. Get your user name and access key
3. Create a test for the app you want to test
4. Update the method to include access key
4. Run the test
5. Check the result
STEP 1: Sign up for a Sauce Labs account.
You can sign up for a free Sauce Labs account, where you get 2 hours of automated testing hours per month on all desktop & mobile browsers
STEP 2: Get your user name and access key.Your access key is listed on this page: https://saucelabs.com/account. Currently its in the bottom left corner. We will be using this access key in combination with your username to interact with Sauce Labs.
STEP 3: Create a test for the app you want to test
We will use the same chess app used in our previous post for our test. You can refer to our previous post to create test case for the chess app. Make sure you have Appium Python Client installed
STEP 4: Update the method to include access key
Update the setUp method to include the username and access key to run your test on sauce Labs
def setUp(self): "Setup for the test" # Using the apk link directly to launch the app app = "http://file.appsapk.com/wp-content/uploads/apps-3/Chess%20Free.apk" self.driver = webdriver.Remote( command_executor='http://$USERNAME:[email protected]:80/wd/hub', desired_capabilities={ 'platformName': 'Android', 'deviceName': 'Android Emulator', 'platformVersion': '4.2', 'app': app, 'name': 'Appium Python Android Test for Chess App', 'appPackage': 'uk.co.aifactory.chessfree', 'appActivity': '.ChessFreeActivity' }) |
STEP 5: Run the test
You can run the test script the normal way you do. We run it via the command prompt.
STEP 6: Check the result
You can see the results on your web account. Login to your Sauce Labs account and you should see a result table like the screen shot below.
And there it is. You learnt how to run Appium tests on Sauce Labs by adding about a dozen lines of Python code to your existing tests.
P.S.: You can use this earlier tutorial to figure out how to parameterize your test to have it run on different browsers.
I am a software tester with over 14 years of experience in software testing. Currently, I am working at Qxf2 Services Bangalore. As a student of the context-driven approach to software testing, I feel there is a lot to learn out there which keeps me very excited. My work has helped me gain good experience in different areas of testing like CRM, Web, Mobile and Database testing. I have good knowledge of building test scripts using Automation tools like Selenium and Appium using Java and Python. Besides testing, I am a “Sports Fanatic” and love watching and playing sports.
Great Job done….
I Salute man!!!