????Appium ????? C/S ????????? Android/iOS Native?? Hybrid ?? Mobile Web Apps ??????????????????? Selenum Webdriver Э??????Webdriver ????????? HTTP RPC ???????? Server ?????????д?????????????????????????? Python?? Java?? NodeJS ???????????д??????????н???? Python ???б???
??????????????г????????????????????????????Щ??????????????????????????????????????????????????????Pass????????? xposed ???? hook ?????????в????????? xposed ??????????????????Pass????????????? UI ?????????????????????????????
????Android UI ????????к??????? Monkey?? UIAutomator?? Selendroid?? Robotium ??????? UIAutomator?? Monkey?? Selendroid ???????????? UI ??????????????????????????????????????в????Robotium ??????????????????Appium ???????????????????????????????????????????????????????????????????? API???? Android 2.3 ?????汾??Appium ????? Selendroid ??????汾???????? UIAutomator??iOS ????? UIAutomation??Appium ????? FirefoxOS ?? UI ?????

??????? Appium
?????????????????????μ???????????????? Appium ?? GUI ?汾????????? Windows/MacOS ????á?Windows ???????? .NET Framework??
????> brew install node      # get node.js
????> npm install -g appium  # get appium
????> npm install wd         # get appium client
????> appium &               # start appium
????> node your-appium-test.js
????Appium ??????? Android SDK ??????????????е??????????????????????????? Android SDK ?汾?????????????? Android Studio ??????? SDK Manager???? SDK Manager ???????????????? SDK Platform ????μ? Build-tools???????????????????????????? ARM/x86 System Image????? Intel HAXM Installer????????? x86 ???????Appium ??? adb ??????????????????????????????????????????????????ν???????????????????
???????????????? Appium GUI ?????? Android SDK ?????????? Android????? Launch ??????? Appium Server??

????Appium Server ??????? http://localhost:4723 ?????? RPC ??????????????????????????????д UI ?????????????????? Python ???б?д????????? Appium ?? Python Client ??????? python ????? appium.webclient ???????? Appium server???
????pip install Appium-Python-Client
??????? Appium ???? UI ????
???????????????????????????в???????????? ADB ?????????????′????Appium ??????????? Appium Settings ?? Unlock ????????????????????
????from appium import webdriver
????desired_caps = {}
????desired_caps['platformName'] = 'Android' #??????
????desired_caps['platformVersion'] = '5.1' #???汾
????desired_caps['deviceName'] = 'm3_note' #?豸????????豸???????
????desired_caps['appPackage'] = 'com.tencent.mm' #app package??
????desired_caps['appActivity'] = '.ui.LauncherUI' #app???Activity
????dr = webdriver.Remote('http://localhost:4723/wd/hub'?? desired_caps) #???Remote RPC
????Selenum Webdriver ?????????????? JS ?е? DOM ????????????????е?????dr ??????????? activity ??????????? findElementByXXX ?????????? Activity ?е????????? Element ??? s ???????????????????????????? s ????????????????????
???????????
????1. findElement(s)ByName
?????? Android ?л?????á?Android UI ??? Name ?????????????????? text ?????????????г??
????2. findElement(s)ByClassName
?????????????????????÷????£?
????item_list = dr.find_elements_by_class_name("android.widget.LinearLayout")
????item_list[2].click()
????3. findElementById
??????? resource_id ???????????? Activity ?ж??????÷?????
????t = dr.find_element_by_id("com.tencent.mm:id/f7")
????t.send_keys(wechatId)
????4. findElement(s)ByAccessbiltiyId
?????? Android ?? AccessbilityID ????? contentDescription ???????????????????????????????????????á????? TTS ???????????????? contentDescription??
????5. findElement(s)ByXPath
??????? XML Path ?????????????????г???????????????? XPath д????????
????s = dr.find_element_by_xpath("//android.widget.TextView[contains(@text??'????')]")
????s.click()
????6. findElementByAndroidUIAutomator
??????? UIAutomator ??????????????????? Appium ?? Android ??????????? UIAutomator???????????? UIAutomator ????????????????
????el = dr.find_element_by_android_ui_automator("new UiSelector().text("????")")
????el.click()
????????????
?????????????????????????????к????????о???????????????????
????click
????send_keys
????clear
??????????????????????????? JS ?е? dom ??????????????ò????????????????????????????
????search = dr.find_element_by_id("com.tencent.mm:id/aqw")
????.find_element_by_class_name("android.widget.RelativeLayout")
????search.click()
?????????????????
????????????????????????? UI ???ж?λ?????????????????????????????????????е????????? resource_id ???ж?λ??????????????? resource_id ??????????????????ж?λ???
????1. UI Automator Viewer
????UI Automator Viewer ?? Android ????? UI ??λ?????λ?? sdk/tools ??????к??? viewer ???檔???????????????????е? Activity ?? UI ????