【问题标题】:ERROR running Appium command: string is not a function运行 Appium 命令时出错:字符串不是函数
【发布时间】:2018-02-03 05:01:18
【问题描述】:

我正在尝试使用 Java 在 Android 移动应用程序上滚动并尝试这些代码;

  JavascriptExecutor js = (JavascriptExecutor) driver;
    HashMap<String, String> scrollObject = new HashMap<String, String>();
    scrollObject.put("direction", "down");
    js.executeScript("mobile: scroll", scrollObject);

Eclipse 出现此错误:

线程“主”org.openqa.selenium.WebDriverException 中的异常: 运行 Appium 命令时出错:字符串不是函数命令 持续时间或超时:7 毫秒

And Appium (version 1.4.16.1) Logs are ;

我也在使用 WebDriver。 我该如何解决这个错误?

【问题讨论】:

  • executeScript 需要一个脚本来执行,你给它一个字符串 hashmap。我相信这可能是你的错误:seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/…
  • @Kathara 谢谢,可能是这样,但这些代码是由 appium 从那里提供的:appium.io/slate/en/master/?java#touchaction 你有什么办法可以解决这个问题吗?
  • 你能告诉我哪一行是android-controller.js中的第690行吗?
  • 689 androidController.scroll = function (direction, cb) { 690 cb(new NotYetImplementedError(), null); 691 };
  • 根据您的日志,这是您的问题发生的地方...

标签: java scroll appium


【解决方案1】:

语法:driver.swipe(startX, startY, endX, endY, duration);

例子:

driver.swipe(200, 900, 200, 100, 2000);

【讨论】:

    猜你喜欢
    • 2016-12-29
    • 1970-01-01
    • 2021-02-20
    • 1970-01-01
    • 2020-12-15
    • 2020-10-31
    • 1970-01-01
    • 1970-01-01
    • 2016-10-14
    相关资源
    最近更新 更多