访问 Android 中的导航栏使用 Appium。

huangapple go评论73阅读模式
英文:

Acessing Navigate Bar in Android With Appium

问题

我需要自动化一个测试,其中包括模拟对导航栏的触摸,不能仅是该命令。

我尝试使用以下代码来模拟触摸:

TouchAction action = new TouchAction(driver);
action.tap(PointOption.point(530, 2400)).perform();

但是出现了错误,指出坐标[x=530.0, y=2400.0]在元素矩形之外。

而且需要模拟在屏幕上触摸。

英文:

I need to automate a test that consists of simulating the touches on the navigate bar, it cannot be just the command.

I tried to simulate the touch with this:

TouchAction action = new TouchAction(driver);
action.tap(PointOption.point(530, 2400)).perform();

But appears the error that the Coordinate [x=530.0, y=2400.0] is outside of element rectangle.

And it needs to be simulating the touch on the screen.

答案1

得分: 4

一个朋友通过阅读您想要点击的页面的 ID,在这种情况下,该 ID 是 "home",已经实现了您所寻找的结果。

public AppiumWebElement HomeTab => AppiumDriver.FindElementById("com.package.appname/home");

然后使用以下内容进行点击:HomeTab.Click();
英文:

A friend of mine have achieved the result you are looking for by reading the id for the page you want to tap on, in this case the id it's home

  public AppiumWebElement HomeTab => AppiumDriver.FindElementById("com.package.appname/home");

and then using the following HomeTab.Click();

huangapple
  • 本文由 发表于 2020年8月26日 23:04:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63600480.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定