import time import unittest #from selenium import webdriver from appium import webdriver desired_caps = {'platformName': 'Android', # 平台名称 'platformVersion': '4.4.2', # 系统版本号 'deviceName': '127.0.0.1:62001', # 设备名称。如果是真机,一般在'设置->关于手机->设备名称'里查看 'appPackage': 'com.youdao.calculator', # apk的包名 'appActivity': 'com.youdao.calculator.activities.MainActivity' # activity 名称 } driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps) # 连接Appium driver.implicitly_wait(6) time.sleep(3) window = driver.get_window_size()#获取手机屏幕 尺寸 x0 = window['width'] * 0.8 # 起始x坐标 x1 = window['width'] * 0.2 # 终止x坐标 y = window['height'] * 0.5 # y坐标 for i in range(0,4): driver.swipe(x0, y, x1, y, 500) #垂直放向手机的中间位置,水平放心从0.8 位置 到0.2位置 time.sleep(2) driver.find_element_by_id('com.youdao.calculator:id/guide_button').click() time.sleep(1) for i in range(6): driver.find_element_by_id('com.youdao.calculator:id/frag_calculator').click() time.sleep(2) # btn_xpath = '/hierarchy/android.widget.frameLayout/android.widget.LinearLayout/android.widget.frameLayout/android.widget.LinearLayout/android.widget.frameLayout/android.widget.frameLayout/android.support.v4.widget.DrawerLayout/android.widget.LinearLayout/android.widget.frameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout[3]/android.view.View/android.widget.GridView/android.widget.frameLayout[{0}]/android.widget.frameLayout' print(btn_xpath.format(7)) driver.find_element_by_xpath(btn_xpath.format(7)).click()#7 driver.find_element_by_xpath(btn_xpath.format(10)).click()#X driver.find_element_by_xpath(btn_xpath.format(8)).click()#8
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)