作者在 2016-04-14 13:20:32 发布以下内容
#-*- coding:UTF-8 -*-
'''
'''
import time
from appium import webdriver
descried_caps={}
descried_caps["unicodeKeyboard"] = "True"
descried_caps["resetKeyboard"] = "True"
descried_caps['device']='2014813'
descried_caps['platformName']='Android'
descried_caps['deviceName']='HM2014813'
descried_caps['version']='5.1'
s = webdriver.Remote("http://127.0.0.1:4723/wd/hub",descried_caps) #固定格式,可以是用
time.sleep(4)
lee.implicitly_wait(4) #智能等待
s.wait_activity(activity, timeout, interval)
s.find_elements_by_android_uiautomator("new UiSelector().className(\"android.widget.CheckedTextView\")")[1].click()
#用UI找对象,后面new UiSelector(). 后面的对象可变
s.find_element_by_android_uiautomator("new UiSelector().text(\"我\")").click()
#
s.find_elements_by_id("com.subject.zhongchou:id/item_name")[1].click()
#通过id的手段找对象,因为多个id的值都一样,所以需要用角标来标识
s.find_element_by_xpath("//android.widget.CheckedTextView[@text='我']").click()
#xpath需要前面加// 示意相对路径,后面跟特征标识码,比如说text
s.tap([(587,1271)],500)
#坐标的用法([(x,y)],毫秒)
time.sleep(2) #s.find_elements_by_android_uiautomator("new UiSelector().className(\"android.widget.CheckedTextView\")")[1].click() print "1" time.sleep(2) x = s.get_window_size()['width'] #获取手机X坐标像素 y = s.get_window_size()['height'] #获取手机Y坐标像素 x = int(x*0.1) y = int(y*0.1) print x,y s.tap([(x*3.2,7.27*y)],50) s.tap([(x*3.2,7.27*y)],50)