id | title | sidebar_label | description | keywords | image | url | site_name | slug | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
appium-python-robot |
Robot With Appium |
Robot |
Now you can run your Appium automation scripts using with Robot on LambdaTest Real Device Cloud Platform of 3000+ real mobile devices. |
|
/assets/images/og-images/appium-testing-og-image.jpg |
LambdaTest |
appium-python-robot/ |
import CodeBlock from '@theme/CodeBlock'; import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
In this topic, you will learn how to configure and run your Robot automation testing scripts with Appium on LambdaTest Real Device Cloud platform.
By the end of this topic, you will be able to:
- Run a sample automation script of Robot for application testing with Appium on LambdaTest.
- Learn more about Desired Capabilities for Appium testing.
- Explore advanced features of LambdaTest.
:::tip Sample repo
All the code samples in this documentation can be found on LambdaTest's Github Repository. You can either download or clone the repository to quickly run your tests. <img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub
:::
Before you can start performing App automation testing with Appium, please make sure:
- You have access to LambdaTest username and accessKey. If you have not registered yet, you can do the same by visiting our website. You will be able to access the credentials in the LambdaTest Profile
- Install the latest stable Python build from the official website.
- Make sure pip is installed in your system. You can install pip from pip documentation.
For mac/linux :
python3 -m virtualenv venv
For mac/linux :
source venv/bin/activate
These commands will create a new virtual environment name venv
and activate it.
Upload your iOS application (.ipa file) or android application (.apk file) to the LambdaTest servers using our REST API. You need to provide your Username and AccessKey in the format Username:AccessKey
in the cURL command for authentication. Make sure to add the path of the appFile in the cURL request. Here is an example cURL request to upload your app using our REST API:
Using App File from System:
Using App URL:
:::tip
-
If you do not have any .apk or .ipa file, you can run your sample tests on LambdaTest by using our sample 🔗 Android app or sample 🔗 iOS app.
-
Response of above cURL will be a JSON object containing the
APP_URL
of the format - lt://APP123456789123456789 and will be used in the next step.
:::
Clone the LambdaTest’s LT-appium-python-robot and navigate to the code directory as shown below:
git clone https://github.com/LambdaTest/LT-appium-python-robot
cd LT-appium-python-robot
Make sure you have your LambdaTest credentials with you to run test automation scripts on LambdaTest. To obtain your access credentials, purchase a plan or access the Automation Dashboard.
Replace LambdaTest username
and accesskey
in the common.robot
file as mentioned below:
*** Settings ***
Library AppiumLibrary
*** Variables ***
// highlight-start
${username} username
${accesskey} accesskey
// highlight-end
${REMOTE_URL} https://${username}:${accesskey}@mobile-hub.lambdatest.com/wd/hub
${TIMEOUT} 3000
*** Keywords ***
Open test app
Open Application ${REMOTE_URL} platformName=${platform} platformVersion=${version} deviceName=${deviceName} visual=${visual} network=${network} isRealMobile=${isRealMobile} app=${app} name=Robot Framework Sample Test build=Appium Python Robot
Close test app
Close Application
To get started, here is an example of sample test on our sample Android and iOS App shown below. You can write or add your own Appium automation scripts in *StepDef.py
directory to run different tests on your app.
*** Settings ***
Resource ../Resources/Common.robot
Test Setup Common.Open test app
Test Teardown Common.Close test app
*** Variables ***
${TIMEOUT} 3000
*** Test Cases ***
Example of connecting to Lambdatest via Robot Framework
[Timeout] ${TIMEOUT}
Click element id=color
Click element id=Text
Click element id=toast
Click element id=notification
Click element id=geoLocation
*** Settings ***
Resource ../Resources/Common.robot
Test Setup Common.Open test app
Test Teardown Common.Close test app
*** Variables ***
${TIMEOUT} 3000
*** Test Cases ***
Example of connecting to Lambdatest via Robot Framework
[Timeout] ${TIMEOUT}
Click element id=color
Click element id=Text
Click element id=toast
Click element id=notification
Click element id=geoLocation
Sleep 2 seconds
Click element id=Home
Sleep 2 seconds
Click element id=speedTest
Sleep 2 seconds
Click element id=Browser
Input Text id=url https://lambdatest.com
Click element id=find
You need to update your capabilities in Makefile
files. In this sample project, we have provided the examples for running tests on both Android and iOS apps. We are passing platform name, platform version, device name and app url (generated earlier) along with other capabilities like build name and test name via capabilities object. The capabilities object in the sample code for a single test are defined as:
test_Android1:
robot --variable version:10 --variable platform:Android --variable deviceName:"Galaxy S20" --variable isRealMobile:true --variable visual:true --variable network:false --variable console:false --variable app:"APP_URL" Tests/Android.robot
test_iOS1:
robot --variable version:14 --variable platform:iOS --variable deviceName:"iPhone 11" --variable isRealMobile:true --variable visual:true --variable network:false --variable console:false --variable app:"APP_URL" Tests/IOS.robot
:::info Note
- You must add the generated APP_URL to the
"app"
capability in the config file. - You can generate capabilities for your test requirements with the help of our inbuilt 🔗 Capabilities Generator tool. For more details, please refer to our guide on Desired Capabilities in Appium.
:::
- Install the required packages from the cloned project directory:
pip install -r requirements.txt
- Execute the following command to run your test on LambdaTest platform:
make test_iOS1
make test_Android1
:::info Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the 🔗 LambdaTest App Automation Dashboard. :::