【发布时间】:2015-05-31 15:04:57
【问题描述】:
是否有任何代码可以点击并按住 Appium?我用python,有什么命令支持吗?
双击我使用了两次点击元素,点击并按住我没有得到任何解决方案
【问题讨论】:
标签: appium
是否有任何代码可以点击并按住 Appium?我用python,有什么命令支持吗?
双击我使用了两次点击元素,点击并按住我没有得到任何解决方案
【问题讨论】:
标签: appium
需要通过驱动
TouchAction action = new TouchAction(driver);
action.longPress(webElement).release().perform();
【讨论】:
是的,您可以使用 TouchAction 类来长按任何元素。试试这个:
TouchAction action = new TouchAction();
action.longPress(webElement).release().perform();
【讨论】:
在以下最新的 Java 客户端版本中可以使用。
AndroidTouchAction touch = new AndroidTouchAction (driver);
touch.longPress(LongPressOptions.longPressOptions()
.withElement (ElementOption.element (element)))
.perform ();
System.out.println("LongPressed Tapped");
【讨论】:
这是Java Client: 5.0.4的更新
WebElement recBtn = driver.findElement(MobileBy.id("img_button"));
new TouchAction((MobileDriver) driver).press(recBtn).waitAction(Duration.ofMillis(10000)).release().perform();
【讨论】:
应该是这样的。持续时间以毫秒为单位计算,因此需要乘以 1000 为 1 秒。
TouchAction action = new TouchAction(driver);
action.longPress(webElement,duration*1000).release().perform();
【讨论】:
这行得通:
TouchActions action = new TouchActions(driver);
action.longPress(element);
action.perform();
【讨论】:
以下工作:
MobileElement longpress = driver.findElement({element find strategy})
LongPressOptions longPressOptions = new LongPressOptions();
longPressOptions.withDuration(Duration.ofSeconds(3)).withElement(ElementOption.element(longpress));
TouchAction action = new TouchAction(driver);
action.longPress(longPressOptions).release().perform();
【讨论】:
一旦您确定了要长按的 pageElement。
//pageElement
editPreferenceButton = driver.whatever
//code for waiting for display of element
waitForDisplayed(editPreferenceButton, 10)
//this line is not required, keeping it here for easy readability
MobileElement longpress = editPreferenceButton;
//use the below code, it will do the trick, credits to wherever i found this
LongPressOptions longPressOptions = new LongPressOptions(); longPressOptions.withDuration(Duration.ofSeconds(3)).withElement(ElementOption.element(longpress));
TouchAction action = new TouchAction(driver);
action.longPress(longPressOptions).release().perform();}
【讨论】: