java - 滑动在 Appium Android Webview 中不起作用

标签 java android selenium webview appium

我使用下面的代码在 WebView 上滑动

 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

最佳答案

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

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

关于java - 滑动在 Appium Android Webview 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33891184/

相关文章:

java - 如何使用project/Build.scala生成java playproject?

java - 无法使用 play 框架应用程序注入(inject)器注入(inject) WSClient

android - Android 游戏开发者使用哪个 OpenGL/3d 框架?

android - 选项卡图标和文本都使用 android 设计支持库

java - 缺少 InitialContext 定义时使用哪个 Java 运行时异常

java - JPA/JPQL 查询错误

android - 在 ProgressDialog 中更改文本对齐方式

python - 元素不可点击,因为另一个元素遮挡了它

java - 如何在日历中选择当前日期和 future 日期

java - List<WebElement> 类型的方法 sendKeys(String) 未定义