Python 上的 Appium 有长按的方法吗? 我需要长按程序中的区域。
def testDevice1(self):
password = self.driver.find_element_by_id('com.e.eas.android:id/password')
password.send_keys('111111')
time.sleep(5)
password = self.driver.find_element_by_id('com.e.eas.android:id/password').longClick()
(Python) 查找 TouchAction。您可以将命令串在一起:
from appium.webdriver.common.touch_action import TouchAction
ta = TouchAction(driver)
ta.press(x=x, y=y).release().perform()
# some_web_obj = driver.find...
ta.press(some_web_obj).wait(duration_in_millisec).release().perform()
from appium.webdriver.common.touch_action import TouchAction
actions = TouchAction(driver)
actions.long_press(element, duration=press_duration_in_ms)
actions.perform()
了解更多信息https://appium.readthedocs.io/en/stable/en/commands/interactions/touch/long-press/
工作解决方案: Python 3.x、Appium 1.22.3、Mac M1
TouchAction(driver).long_press(element).release().perform()
由于
TouchAction
现已弃用,请使用 ActionChains
代替。下面是一个简单的例子:
actions = ActionChains(self.driver)
actions.move_to_element(element)
actions.click_and_hold()
actions.pause(2)
actions.perform()