2015年2月4日 星期三

Robot Framework + Appium - Android WiFi ON/OFF Demo

Win 8 + Android

環境建置

  • Python
  • Java Run Time
  • Easy Install & pip
  • 環境變數 PATH 設定:[python], [python]\Scripts, [jython]\bin, [jre]\bin
  • RobotFramework
  • wxPython (for RIDE)
  • RIDE
  • Appium
  • Robot Framework Library
    • AppiumLibrary (for Android)
      $ pip install robotframework-appiumlibrary


前置作業

  • 確認有連接的 Android Device / Emulator
  • 啟動 Appium Server
    $ appium

執行測試


*** Settings ***
Suite Teardown    Clean up
Library           AppiumLibrary
Library           OperatingSystem
Library           String

*** Test Cases ***
Wi-Fi OFF/ON
    Launch Settings
    Enter Wifi Sub-menu
    Turn OFF
    Turn ON
    Back
    Home

*** Keywords ***
Clean up
    Stop All Processes
    Close All Applications

Launch Settings
    Launch Buildin App    ${APPNAME_Settings}

Enter Wifi Sub-menu
    Click Element    //android.widget.TextView[contains(@text,'Fi')]
    Default Wait

Turn OFF
    Run Keyword And Ignore Error    Click Element    

//android.widget.Switch[@text='ON']
    Wait Until Page Contains    Off    30

Turn ON
    Run Keyword And Ignore Error    Click Element    

//android.widget.Switch[@text='OFF']
    Wait Until Page Contains    On    30

Back
    Press Keycode    4
    sleep    1

Home
    Press Keycode    3
    sleep    1


2 則留言:

>
  1. Hello,想請問Launch Buildin App/Stop All Processes 不是keyword要怎麼辦呢?

    回覆刪除
  2. That is very interesting I love reading and I am always searching for informative information like this.

    Online Robot Framework Training

    回覆刪除