【问题标题】:Swipe is not working in Appium Android Webview滑动在 Appium Android Webview 中不起作用
【发布时间】:2016-02-26 17:57:26
【问题描述】:

我正在使用下面的代码在网页视图上滑动

 driver.findElement(By.xpath("//*[@id=\"mainSec\"]/section/div[2]/div/div[2]/div/input[1]")).sendKeys(username);

 driver.findElement(By.xpath("//*[@id=\"mainSec\"]/section/div[2]/div/div[2]/div/input[2]")).sendKeys(password);
 driver.findElement(By.xpath("//*[@id=\"mainSec\"]/section/div[2]/div/div[3]/button")).click();
 Thread.sleep(20000);
 driver.swipe(944, 1100, 110, 1100, 2000);

遇到错误

在 Appium 服务器上

> info: --> POST /wd/hub/session/71ff38f1-3e77-44ef-b4af-d2ab69970112                        
 /touch/perform {"actions":[{"action":"press","options": {"x":944,"y":1100}},{"action":"wait","options":{"ms":2000}},{"action":"moveTo","options":{"x":110,"y":1100}},{"action":"release","options":{}}]}
> info: JSONWP Proxy: Proxying [POST /wd/hub/session/71ff38f1-3e77-44ef-b4af-d2ab69970112/touch/perform] to [POST http://127.0.0.1:9515/wd/hub/session/9effe9253998eaad03f14d1cc5ef148c/touch/perform] with body: {"actions":[{"action":"press","options":{"x":944,"y":1100}},{"action":"wait","options":{"ms":2000}},{"action":"moveTo","options":{"x":110,"y":1100}},{"action":"release","options":{}}]}
> info: JSONWP Proxy: Got response with status 404: unknown command: session/9effe9253998eaad03f14d1cc5ef148c/touch/perform

在 Eclipse TestNG 上

 org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
 Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
 System info: host: 'IN2084073W1', ip: '10.165.162.203', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_21'
 Driver info: driver.version: AppiumDriver

【问题讨论】:

标签: java android selenium webview appium


【解决方案1】:

使用 TouchAction 类执行滑动。像这样:

TouchAction action = new TouchAction(driver).longPress(longPress).moveTo(moveTo).release();
action.perform();

【讨论】:

  • 抱歉回复晚了。我已尝试使用您提供的代码。现在我在 appium 服务器或 TestNG 上没有收到任何错误。我的方法通过了。但无法看到元素正在被刷卡。请帮忙。这是代码 TouchAction act = new TouchAction(driver); act.longPress(604, 762,1000).moveTo(117, 762).release();
  • @Hashili 你找到解决方案了吗?我也遇到了类似的问题,谢谢。
  • @DrPatience 是的,它在尝试使用 x,y 坐标和延迟的 driver.swipe 方法时对我有用......如果这对你不起作用......只需将上下文切换到NATIVE APP 就在此滑动方法之前并尝试
【解决方案2】:

也许你可以将上下文切换到原生,比如

driver.context("NATIVE_APP");

然后,滑动可以工作,就像

driver.swipe(500, 1600, 500, 600, 1000);

【讨论】:

    猜你喜欢
    • 2018-11-11
    • 1970-01-01
    • 2020-11-04
    • 2018-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    相关资源
    最近更新 更多