如何使用 appium 点住(长按)Android?
How to tap and hold (Long press) using appium for Android?
Appium 有长按代码吗?我使用 python ,有什么命令支持它吗?
对于双击,我使用了两次单击元素,对于点击并按住,我没有得到任何解决方案
是的,您可以使用 TouchAction class 来长按任何元素。试试这个:
TouchAction action = new TouchAction();
action.longPress(webElement).release().perform();
需要通过驱动程序
TouchAction action = new TouchAction(driver);
action.longPress(webElement).release().perform();
这是 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();
在最新的 Java 客户端版本中可以使用。
AndroidTouchAction touch = new AndroidTouchAction (driver);
touch.longPress(LongPressOptions.longPressOptions()
.withElement (ElementOption.element (element)))
.perform ();
System.out.println("LongPressed Tapped");
这个有效:
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();}
Appium 有长按代码吗?我使用 python ,有什么命令支持它吗?
对于双击,我使用了两次单击元素,对于点击并按住,我没有得到任何解决方案
是的,您可以使用 TouchAction class 来长按任何元素。试试这个:
TouchAction action = new TouchAction();
action.longPress(webElement).release().perform();
需要通过驱动程序
TouchAction action = new TouchAction(driver);
action.longPress(webElement).release().perform();
这是 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();
在最新的 Java 客户端版本中可以使用。
AndroidTouchAction touch = new AndroidTouchAction (driver);
touch.longPress(LongPressOptions.longPressOptions()
.withElement (ElementOption.element (element)))
.perform ();
System.out.println("LongPressed Tapped");
这个有效:
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();}