当前位置: 首页 > 知识库问答 >
问题:

使用TouchAction可以吗。按

乜栋
2023-03-14

目前,我正在为ios ionic应用程序编写一个Appium脚本,我使用以下方法来实现滑动功能。

public void swipeHorizontal(AppiumDriver<MobileElement> driver, double startPercentage, double finalPercentage, int duration) throws Exception {
    Dimension size = driver.manage().window().getSize();
    int width = (int) (size.width/2);
    int startPoint = (int) (size.getHeight()*startPercentage);
    int endpoint = (int) (size.getHeight()*finalPercentage);
    new TouchAction(driver).press(width,startPoint).waitAction(Duration.ofSeconds(0)).moveTo(width,endpoint).release().perform();
   }

在上面的方法中,单词press,waitAction

共有1个答案

楚意
2023-03-14

任何时候,当你看到某个东西被“弃用”时,这意味着虽然它在技术上仍然受支持,但它的支持只是为了让现有(遗留)应用程序继续运行,并且一些新的、据说更好的东西取代了它,你应该改为使用新方法。

现在在Appium中有了一个滑动方法,它使事情变得简单多了。以下是我使用滑动的代码:

/**
 * This method performs a swipe on an Android element
 * @author Bill Hileman
 * @param element - an Android element, i.e. an EditView, TextView, etc.
 * @param locator - a verbal description of the element for logging purposes
 * @param direction - a value of type SwipeElementDirection
 * @param duration - time in milliseconds for the swipe to complete
 */
public void swipe(AndroidElement element, String locator, SwipeElementDirection direction, int duration) {

    try {
        element.swipe(direction, duration);
    } catch (NullPointerException | NoSuchElementException e) {
        System.err.println("Unable to locate element '" + locator + "'");
        fail();
    } catch (Exception e) {
        System.err.println("Unable to swipe " + direction.toString() + " element '" + locator + "'");
        e.printStackTrace();
        fail();
    }

}
 类似资料:
  • 问题内容: 这是此问题的后续操作- 想创建一个表单填充器-java,jsp,html是否足够?。我反复在网站上填写表格(例如,预约私人牙医)。 1-循环。对于每次迭代,除“下拉框-状态”的值外,所有数据均相同。 例如。每次迭代中“文本框-名称”,“文本框-年龄”保持不变。但是,状态下拉列表会在迭代中更改为NY,TX,CA。 2-如果最后一页中出现某些文本,请执行一项操作(发送邮件)。 我该如何做s

  • 问题内容: 我看到可以从IronPython使用numpy: https://www.enthought.com/repo/.iron/ 是否可以在IronPython中安装和导入scikit?我试图在用scikit用python 2.7编写的模块和使用IronPython的外部COM对象之间进行接口… 谢谢 问题答案: IronPython肯定不受scikit- learn的支持,我怀疑它是否会

  • 我想使用而不使用。我们有一个与Spring现有的项目,但我有麻烦配置没有。 当我使用@EnableZuulProxy注释时,出现以下错误: 原因:org。springframework。豆。工厂UnsatifiedPendencyException:创建名为“org”的bean时出错。springframework。云netflix。祖尔。ZuulProxyConfiguration”:通过字段“

  • 问题内容: 我面临的问题是回报。当用于仅接受非空类型的模拟方法时,它将导致引发“应该不为空”异常。 模拟方法: 问题答案: 有两种可能的解决方法: 另一个解决方法是 这是有关此主题的更多讨论,其中首先提出了解决方法。

  • 本文向大家介绍没有ZooKeeper可以使用Kafka吗?相关面试题,主要包含被问及没有ZooKeeper可以使用Kafka吗?时的应答技巧和注意事项,需要的朋友参考一下 答:绕过Zookeeper并直接连接到Kafka服务器是不可能的,所以答案是否定的。如果以某种方式,使ZooKeeper关闭,则无法为任何客户端请求提供服务。

  • 我对Docker相当陌生,我最近开始运行ubuntu容器,并在几天后优雅地停止了它(我没有看到它使用“Docker PS”)。当我试图用