在小程序列表中长按删除总是报错
来源:1-1 课程目标及课程规划-导学

慕仰0001042
2019-11-26
from appium import webdriver
import time
from appium.webdriver.common.touch_action import TouchAction
import unittest
import traceback
desired_caps = {
'platformName':'Android',
'platformVersion':'9',
'deviceName':'21a9d094',
'appPackage': 'com.tencent.mm',
'appActivity': '.ui.LauncherUI',
# 'unicodeKeyboard': True,
# 'resetKeyboard': True,
'noReset': True,
'chromeOptions': {'androidProcess': 'com.tencent.mm:appbrand0'}
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
time.sleep(5)
def delete_mini_lefthand(driver):
"""
从最近使用中删除左手医生小程序
:param driver:
:return:
"""
l = driver.get_window_size()
print(l['width'],l['height'])
x1 = l['width'] * 0.5 # x坐标
y1 = l['height'] * 0.25 # 起始y坐标
y2 = l['height'] * 0.75 # 终点y坐标
driver.swipe(x1, y1, x1, y2, 500)
time.sleep(5)
try:
element = driver.find_element_by_xpath("//*[@text='左手医生']")
TouchAction(driver).long_press(el=element,duration=2000).move_to(x = 468,y = 2029).release().perform()
time.sleep(3)
except Exception as e:
traceback.print_exc()
print(e,"找不到左手医生小程序")
finally:
driver.swipe(l['width']*0.5,l['height']*0.98, l['width']*0.5, l['height']*0.5,1000)
print("返回到微信首页")
delete_mini_lefthand(driver)
3回答
-
Mushishi
2019-11-29
仔细看哟。然后先去找元素,看你找得到不。然后再去操作。
00 -
Mushishi
2019-11-29
看你的错误,不是长按,是你这个元素都没找到。00 -
Mushishi
2019-11-28
已经增加了try,你的错误抛出是多少行呢?那个上面的错误信息发一下
022019-11-29
相似问题