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

无法在appium iOS测试上滑动

百里胜泫
2023-03-14

在文档中,appium为java提供了以下选项:

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put("startX", 0.01);
swipeObject.put("startY", 0.5);
swipeObject.put("endX", 0.95);
swipeObject.put("endY", 0.5);
swipeObject.put("duration", 1.8);
js.executeScript("mobile: swipe", swipeObject);

我在测试中集成了这一点,但在导航到可以使用swipe的屏幕后,使用swipe的方法将不会执行该操作。。。在故障异常面板中,我收到以下错误:“org.openqa.selenium.WebDriverException:尚未实现”。

我想从左向右滑动,但还没有找到其他解决方案。。。

更新:我已经设法通过使用以下代码刷:

HashMap scrollObject = new HashMap();{{
    scrollObject.put("direction", "left");
}};
((RemoteWebDriver) driver).executeScript("mobile: scroll", scrollObject);

问题是,它将只刷一次,即使使用多次。。。有没有办法解决这个问题?

共有2个答案

郭琨
2023-03-14

请参考此问题的详细RCA与解决方案

问题是iOSappium java客户端植入了不同的刷卡功能!

对于Android,它的参数名endx和endy是endpoint坐标!

但是对于iOS,如果命名正确,它们是deltaX和deltaY。

简言之,

Positive endx = Right direction and magnitude of endx defines swipe size
Negative endx = Left direction and magnitude of endx defines swipe size
Positive endy = Down direction and magnitude of endy defines swipe size
Negative endy = UP direction and magnitude of endy defines swipe size

StartX和StartY是笔划起点的坐标!

让我们举个例子

1. swipe(100,200,10,20,300) => swipe starting from Point (100,200) and end at Point (110,220) which means finger would move Right lower side fro current position
2. swipe(100,200,-10,20,300) => swipe starting from Point (100,200) and end at Point (90,220) which means finger would move Left lower side from current position
3. swipe(100,200,10,-20,300)=> swipe starting from Point (100,200) and end at Point (110,180) which means finger would move Right Upper side from current position
4. swipe(100,200,-10,-20,300)=> swipe starting from Point (100,200) and end at Point (90,180) which means finger would move Left Upper side from current position
端木夕
2023-03-14

使用IOSDriver(driver)并调用以下命令如何:

    driver.swipe(100, 100, 500, 500, 500);
 类似资料:
  • 我在尝试使用ios应用程序上的滑动功能时遇到问题。目前正在将Appium v1.3.5与Cucumber/RubyMine v7.04联合使用。 我尝试使用一个范围的x,y坐标。然而,我仍然只能刷一半,无法点击屏幕上的元素。 以前有人遇到过这个问题吗? 请发送错误消息:

  • 我想在ios上设置wifi状态,为此,我需要从控制中心底部向上滑动。 在我将java客户端升级到4.0.0和appium升级到1.5.2之前,它工作正常。 我得到一个错误:error:VerboseError:point不在屏幕范围内 记录如下: 知道是怎么回事吗? 谢谢

  • 我是自动化新手,尝试使用Appium(Mac应用程序)在iOS应用程序上编写测试脚本。 我成功地在Appium上加载了我的应用程序,并使用了Appium Inspector。在Appium inspector中有一个记录按钮,用于记录我的操作。 但是,我的问题是如何保存这些录制的脚本以供重用?其次,我还想使用Java手动编写测试脚本,但目前不知道在哪里使用Appium Mac app编写代码。 我

  • 我正在尝试使用IntelliJ Community edition和Gradle5.5.1运行一个Cucumber/Selenium项目。 我的TestRunner类如下:

  • 我有一些Selenium Webdriver测试,希望使用mvn-test从命令行运行。问题是,我可以清理,构建和编译没有问题,但没有测试运行。我没有收到任何与测试有关消息,如“There are no tests to run”。 我的junit测试遵循*Test类命名约定。 编辑:好的,我发现这是一个配置文件的问题-修复!

  • 本地:- 我正在尝试在chrome浏览器上运行硒测试。 当前,另一个chrome浏览器正在运行,然后通过打开新配置文件在chrome browser上运行测试,并得到以下错误:- Chrome驱动配置:- 如果我关闭现有的正在运行的chrome浏览器,然后在chrome浏览器上运行硒测试,它可以工作。 詹金斯:- 当我试图在詹金斯上跑步时。我收到以下错误:- 这里的问题是什么,有人能帮我解决这个吗