使用 appium whlie 客户端在 Android 设置中访问切换按钮是用 groovy 和 java 编写的 [英] Access toggle button in Android settings using appium whlie client is written in groovy and java

查看:12
本文介绍了使用 appium whlie 客户端在 Android 设置中访问切换按钮是用 groovy 和 java 编写的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<块引用>

它不是重复的.

我正在

为了自动点击这个页面,我创建了一个代表这个屏幕的页面对象.在这种情况下,我只对切换

所以我的初始化是这样的来访问 switch Widget.

SwitchID { $("#switchWidget") }

显然,当我运行功能文件时,Appium 无法找到这个开关小部件.但是我可以在我正在处理的应用程序中自动化其他小部件.但是我在android的这个设置屏幕上什么也得不到.

任何帮助都会受到高度重视.谢谢

解决方案

您可以访问 UI 上的任何可见组件.无论是按钮/开关还是其他任何东西.
有几种方法可以使用 Appium/Selenium 驱动程序访问元素 - 通过名称/id/xpath 等
使用 UIAutomator 捕获该可见元素的 id/name/content desc 就大功告成了!
在您的情况下,正如我在 UIAutomator 屏幕截图中看到的那样-您同时获得了 id 和 name.因此,您可以使用它们中的任何一个来单击所需的元素.
(你可以从 Appium 中参考你相关的 groovy/java 语法)
http://appium.io/introduction.html

It's not a duplicate.

I am writing automation in Appium. I am fairly new to automation concept and Appium it self. I am using java-client.

I have a scenario in which my android app for which I am writing automation, has to take android permission. My application navigates to following setting page of Android Settings as shown below.

To automate clicks on this page I have created a Page Object which would represent this screen. in this scenario I am only interested in toggling the Switch and to learn how to get it's state.

I could get resource id for the UI Automator Viewer something like this.

So my initialization is something like this to access the switch Widget.

SwitchID { $("#switchWidget") }

Apparently, When i run the feature file, Appium is not able to find this switch widget. But I can automate other widget inside the application I am working on. but I can't get anything on this setting screen of android.

Any help would be highly regarded. Thanks

解决方案

You can access any visible component on UI. Be it buttons/ switches or whatever.
There are several ways to access an element using Appium/ Selenium driver - By name/ id/ xpath, etc.
Use UIAutomator to capture that visible element's id/name/ content desc and you're done!
In your case, as I can see in UIAutomator screenshot - you are getting both id and name. So you can use any of them to click your desired element.
(You can refer to your relevant groovy/java syntax from Appium)
http://appium.io/introduction.html

这篇关于使用 appium whlie 客户端在 Android 设置中访问切换按钮是用 groovy 和 java 编写的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆