appium 长按而不是移动元素(拖放)不起作用
appium long press and than move element(drag and drop) is not working
我有一个场景可以像这样测试 IOS 应用程序:
- long press on an element.
- move that element to desired location.
我正在使用以下代码:
TouchAction action = new TouchAction(driver)
action.long_press(element1).move_to(element2).wait(500).release().perform()
但它对我不起作用。需要什么好的建议。
我也为此烦恼。但是我像下面这样解决了这个问题:
TouchAction action = new TouchAction(driver);
action.longPress(elem1).waitAction(3000).moveTo(elem2).perform().release();
waitAction
将等待完成 longPress
操作,然后 moveTo
操作将执行。
action.press(Element1).moveTo(Element2).release().perform();
我发现 none 的 longPress() 组合可以工作,所以我得到了这个变体,你可以强制它执行按压然后移动。在 Android 和 iOS 上测试过,似乎不适用于 UWP
new TouchAction(driver)
.press(PointOption.point(256, 1115))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))
.perform()
.moveTo(PointOption.point(256, 600))
.release()
.perform();
//You need to import following
import org.openqa.selenium.WebElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.LongPressOptions;
import io.appium.java_client.touch.offset.ElementOption;
//first for the intial location to be long pressed
WebElement first= driver.findElementByXPath("//*[@content-desc='15']");
//second location on which you need to move to
WebElement second= driver.findElementByXPath("//*[@content-desc='45']");
TouchAction action = new TouchAction(driver);
//performing the long press
action.longPress(new LongPressOptions().withElement(new
ElementOption().withElement(first))).perform();
//performing the move to touch operation
action.moveTo(new ElementOption().withElement(second)).perform();
if U have references of elements already then you'll do like this:
TouchAction action = new TouchAction(driver);
action.longPress(new ElementOption().withElement(first))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(3000)))
.moveTo(new ElementOption().withElement(last))
.release()
.perform();
我有一个场景可以像这样测试 IOS 应用程序:
- long press on an element.
- move that element to desired location.
我正在使用以下代码:
TouchAction action = new TouchAction(driver)
action.long_press(element1).move_to(element2).wait(500).release().perform()
但它对我不起作用。需要什么好的建议。
我也为此烦恼。但是我像下面这样解决了这个问题:
TouchAction action = new TouchAction(driver);
action.longPress(elem1).waitAction(3000).moveTo(elem2).perform().release();
waitAction
将等待完成 longPress
操作,然后 moveTo
操作将执行。
action.press(Element1).moveTo(Element2).release().perform();
我发现 none 的 longPress() 组合可以工作,所以我得到了这个变体,你可以强制它执行按压然后移动。在 Android 和 iOS 上测试过,似乎不适用于 UWP
new TouchAction(driver)
.press(PointOption.point(256, 1115))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))
.perform()
.moveTo(PointOption.point(256, 600))
.release()
.perform();
//You need to import following
import org.openqa.selenium.WebElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.LongPressOptions;
import io.appium.java_client.touch.offset.ElementOption;
//first for the intial location to be long pressed
WebElement first= driver.findElementByXPath("//*[@content-desc='15']");
//second location on which you need to move to
WebElement second= driver.findElementByXPath("//*[@content-desc='45']");
TouchAction action = new TouchAction(driver);
//performing the long press
action.longPress(new LongPressOptions().withElement(new
ElementOption().withElement(first))).perform();
//performing the move to touch operation
action.moveTo(new ElementOption().withElement(second)).perform();
if U have references of elements already then you'll do like this:
TouchAction action = new TouchAction(driver);
action.longPress(new ElementOption().withElement(first))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(3000)))
.moveTo(new ElementOption().withElement(last))
.release()
.perform();