英文:
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();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论