Appium中长按按钮操作

在一次项目中,appium要对某个按钮进行长按操作(大于2s),类似拍微信小视频,参考网上长按视频会报错

action1 = TouchActions(self.driver)  
el = self.driver.find_element_by_name('按住拍')  
action1.long_press(el).wait(10000).perform() 

报错如下:

解决方法,使用以下代码可以解决:

action1=TouchActions(self.driver)
e1=self.driver.find_element_by_name('按住拍')
action1.tap_and_hold(540,1800).perform()
time.sleep(10)
action1.release(540.1800).perform()

 特此记录!!

原文地址:https://www.cnblogs.com/landhu/p/4969396.html