from?appium?import?webdriver
from?utils.appiumtools?import?find_element
#?from?utils.appiumtools?import?find_element
import?time
desired_caps?=?{}
desired_caps['platformName']?=?'Android'????????????????????#?打開什么平臺的app上枕,固定的?>?啟動安卓平臺
desired_caps['platformVersion']?=?'7.1.2'???????????????????#?安卓系統的版本號:adb?shell?getprop?ro.build.version.release
desired_caps['deviceName']?=?'V1923A'????????????????#?手機/模擬器的型號:adb?shell?getprop?ro.product.model
desired_caps['appPackage']?=?'com.tencent.mobileqq'???????????????#?app的名字:
????????????????????????????????????????????????????????????#?安卓8.1之前:adb?shell?dumpsys?activity?|?findstr?"mFocusedActivity"
????????????????????????????????????????????????????????????#?安卓8.1之后:adb?shell?dumpsys?activity?|?findstr?"mResume"
desired_caps['appActivity']?=?'.activity.SplashActivity'??????????????#?同上↑
desired_caps['unicodeKeyboard']?=?True??????????????????????#?為了支持中文
desired_caps['resetKeyboard']?=?True????
desired_caps['noReset']?=?True???#使用app緩存
????????????????????????#?設置成appium自帶的鍵盤
????#?去打開app溜徙,并且返回當前app的操作對象
driver?=?webdriver.Remote('http://localhost:4723/wd/hub',?desired_caps)
time.sleep(5)
driver.tap([(67,98)],?5)
toux?=?('xpath','/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.TabHost/android.widget.FrameLayout/android.widget.RelativeLayout[2]/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.FrameLayout[2]/android.widget.ImageView[2]')
zan?=?('xpath','//android.widget.FrameLayout[@content-desc="11089次贊"]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ImageView')
find_element(driver,toux,?20).click()
find_element(driver,zan,?20).click()