Pages

Wednesday, August 2, 2017

Appium with Selenium Robot framework

When we get to the topic of Native & Hybrid automation, Appium is one of a great solution I have ever found. It’s an open source test automation framework that drives iOS, Android, and Windows applications.

Appium support any automation framework and can be use with any programming language. So, if you are good with Selenium Robot framework, get ready to develop your first automation script after reading this blog.
Note - This article is focus on android automation. 


Installation...

    • add 'tools' and 'platform-tools' folders to PATH variable

  • Install the latest Appium library (robotframework-appiumlibrary 1.4.4) from https://pypi.python.org/pypi/robotframework-appiumlibrary/
    • > pip uninstall robotframework-appiumlibrary  (To uninstall previous version of appium library (if any))
    • > cd C:\Python27\Scripts\robotframework-appiumlibrary-1.4.4 (Go to the directory which include appium library)
    • > python setup.py install
Launch Application using Appium...
  • Execute 'Appium.exe' to launch Appium
    • Set Application path & other parameters.
    • Click 'Run' button in the top right hand corner to start Appium server & Launch the application using attached device or emulator.

 Connect AVD (Android Virtual Device) or Real device...

  • If you are connect a real device, use 'adb devices' command to get the deviceName. (adb is located inside the 'platform-tools' folder) deviceName is one of the Appium server capability which is used with 'Open Application' keyword in your robot script. you will learn these keywords and capabilities later. 
  • If use don't have a actual device, then you should boot a AVD (Emulator) with API Level 17 or greater. see above image. you can see 'Launch AVD' parameter.
       How to create an AVD ?
  • Open 'AVD Manager.exe' which is located inside the SDK folder (..\AppData\Local\Android\sdk)
  • Create a new AVD

Locating elements in Android apps...

  • 'uiautomatorviewer' is a great tool comes with SDK that helps to get element's XPath, ID, Name And className. it is located inside the tools folder. (..\AppData\Local\Android\sdk\tools)

Take the above image. Few examples of how to locate the serverIP text field are given below.
  • Locating element by resource-id : id=com.qmatic.concierge:id/et_ip
  • Locating element by class and resource-id : xpath=//android.widget.EditText[contains(@resource-id,'com.qmatic.concierge:id/et_ip')]
  • Locating element by class and index : xpath=//android.widget.EditText[@index='1']
Write your first code...
*** Settings ***
Documentation This resource file contains global variables and keywords
... [Author]  Nishantha Thilakawardana

Library           AppiumLibrary 20


*** Variables ***
${REMOTE_URL}                   http://localhost:4723/wd/hub
${PLATFORM_NAME}          Android
${PLATFORM_VERSION}    6.0.1
${DEVICE_NAME}                 Galaxy Tab S2
${APP}                                         F:\\Projects\\Orchestra_Mobile_Connect_Concierge-1.1.1.7.apk
${TIME OUT}       20 sec
${Retry_Int}        3 sec

*** Test Cases ***
Concierge_Login
    [Documentation]    Android Automation for MobileConnectConcierge
    [Tags]    demo

    submit system settings

*** Keywords ***
submit system settings
    Open Application  ${REMOTE_URL}  platformName=Android  platformVersion=${PLATFORM_VERSION}  deviceName=${DEVICE_NAME} app=${APP}  automationName=appium  appPackage=com.qmatic.concierge
    Clear Text id=com.qmatic.concierge:id/et_ip
    Input Text     id=com.qmatic.concierge:id/et_ip                X.X.X.X
    Clear Text id=com.qmatic.concierge:id/et_port
    Input Text     id=com.qmatic.concierge:id/et_port       XXXX
    Click Element     id=com.qmatic.concierge:id/btnConnect


I assume, you have a fair knowledge of selenium robot framework and keyword driven development to understand the above script.
You can find the complete keyword documentation here.
Also you can find the complete list of key codes which can be use with keyword "Press Keycode" here.

So, I hope this 
article help beginners who like to acquire some basics of Android automation. Lets meet soon with another technical stuff. have a great day!



11 comments:

  1. Great Content. It will useful for knowledge seekers. Keep sharing your knowledge through this kind of article.
    IELTS Writing Skills
    IELTS Writing Tasks

    ReplyDelete
  2. Thank you for the useful information. Share more updates.
    Vocabulary
    IELTS Map


    ReplyDelete
  3. During a OctaFx Review workshop, each attendee will learn how to interpret market action using proven charting techniques, searching for reliable chart patterns and indicators to help them identify trading opportunities.

    ReplyDelete
  4. This post is so useful and informative. Keep updating with more information.....
    IELTS Certification
    IELTS Coaching

    ReplyDelete

Blogger news

Blogroll

What's Hot