Appium、Python中长按方法

问题描述 投票:0回答:4

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 appium long-click
4个回答
0
投票

(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()

0
投票
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/


0
投票

工作解决方案: Python 3.x、Appium 1.22.3、Mac M1

    iOS 上的
  • 长按可以使用snippet
  • 实现

TouchAction(driver).long_press(element).release().perform()


0
投票

由于

TouchAction
现已弃用,请使用
ActionChains
代替。下面是一个简单的例子:

actions = ActionChains(self.driver)
actions.move_to_element(element)
actions.click_and_hold()
actions.pause(2)
actions.perform()
© www.soinside.com 2019 - 2024. All rights reserved.