Appium中的“点击”和“点击”触摸动作之间有何区别?

时间:2020-01-15 07:38:12

标签: appium appium-android

我想知道使用Appium Driver时点击和按下元素之间的区别。

我能够理解“点击”和“点击”之间的区别,但无法清除关于“点击和按下”的知识。我能确定的唯一区别是水龙头对位置和元素都有效,而新闻似乎只对位置起作用。

但是即使那样,我仍然可以使用tap来处理位置点击和元素点击。为什么我们需要明确地新闻? 他们似乎在UI上执行相同的功能。有人可以向我解释一个用例,在该用例中,我们需要明确进行点击,而不是按动,反之亦然。

下面是我同时使用的代码:

点击:

t.tap(tapOptions().withElement(ElementOption.element(MY_WEBELEMENT))).perform();

按下:

t.press(PointOption.point(0, 1200)).release().perform();

我是Appium测试的新手,仍在努力改善这些基础知识。也可以随时引导我阅读任何现有的文档。

1 个答案:

答案 0 :(得分:1)

df1 <- structure(list(ID = c(30761L, 30762L, 30763L, 30764L, 30765L, 30765L, 30766L, 30766L, 30767L, 30767L, 30768L, 30768L, 30769L, 30769L, 30770L, 30771L, 30772L, 30772L, 30773L, 30773L, 30774L ), Direction = c("River", "Marine", "Marine", "Marine", "River", "River", "Marine", "River", "River", "River", "River", "River", "River", "River", "River", "River", "River", "River", "River", "River", "River")), class = "data.frame", row.names = c("100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120")) Tap都适用于Element和Coordinate。看看。

假设我有此移动元素,坐标和时长。

Press

点击元素

MobileElement myElement;
    int xPoint, int yPoint;
    int duration = XXXX; //in miliseconds

点击坐标

new TouchAction(localdriver).tap(tapOptions().withElement(element(myElement))).perform();

使用相对于元素的坐标点击元素:

new TouchAction(localdriver).tap(point(xPoint, yPoint)).perform();

长按元素:

new TouchAction(localdriver).tap(tapOptions().withElement(element(myElement, xPoint, yPoint))).perform();

长按元素的持续时间:

new TouchAction(localdriver).longPress(longPressOptions().withElement(element(myElement))).release().perform();

长按坐标:

new TouchAction(localdriver).longPress(longPressOptions().withElement(element(myElement)).withDuration(Duration.ofMillis(duration))).release().perform();