Automated Testing With Appium and Robot Framework
Installation
(These instructions assume python is installed. This was tested with Mac so, they might vary for other OS)
- Install Appium. For Detailed Instructions
- Install pip for Python. Instructions
-
Install Robot. For Detailed Instructions
pip install robotframework
-
Install Appium Library from the link or use the following command.
pip install robotframework-appiumlibrary
Keyword Reference
Writing our first TestCase
We are going to use UICatalog app that is available on Apple’s website. We are dealing with 11.3 version here.
-
Compile UICatalog.app with either Xcode or commandline
For commandline, Command is –
xcodebuild -configuration ${BUILD_TYPE} -target ${TARGET_NAME} -arch ${CPU_ARCHITECTURE} -sdk ${SIMULATOR_OR_IOS_SDK}
where –
{Build_Type}
–Release
orDebug
{Target_Name}
–{CPU_ARCHITECTURE}
–i386
for Simulator,armv6
orarmv7
for DevicesSIMULATOR_OR_IOS_SDK
– Essentially looking foriPhone
oriPhoneSimulator
So our commands would look like –
cd <UICatalog folder containing *.xcodeproj file>
rm -rf build
(Assuming you have build folder)-
if you are building for Simulator
xcodebuild -configuration Release -target UICatalog -arch i386 -sdk iphonesimulator8.2
- Or if you are building for iPhone
-
With Keys (In my case Found under KeyChains ->Login->My Certificates) -
xcodebuild -configuration Release -target UICatalog -arch armv7 -sdk iphoneos8.2 CODE_SIGN_IDENTITY="iPhone Developer: user"
You may need to allow access to keys which is done by- Right clicking Certificate->GetInfo->”Always Trust”
- Right clicking Key->GetInfo->Access Control -> “Allow all applications to …”
- With Provision Profile(Found under ~/Library/MobileDevice/Provisioning\ Profiles/ –
-
xcodebuild -configuration Release -target UICatalog -arch armv7 -sdk iphoneos8.2 PROVISIONING_PROFILE="<uuid>"
-
ls build/Release-iphonesimulator/
(To List UICatalog.app)
-
Create a Robot file
Robot files contain Settings, Variables, Keywords and TestCases. Some keywords are already predefined by the plugin. Rest we need to define them. You can see them in the Sample File. We are going to do following Testcases -
- Open Application
- Check Element Exists
- Check Element with Text Exists
- Click the Element
- Scroll in the list
- Put application to Background
- Close the application
- Close any other application.
(Last two Test cases are important to ensure Appium closes the session properly) You can find the sample file here