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

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

问题描述


它不是重复的。


我在



要自动点击此页面,我已经创建了一个表示此屏幕的页面对象。在这种情况下,我只想切换


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

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

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