ionic-framework - 使用 appium 单击“离子切换”
问题描述
我无法<ion-toggle>
使用 appium/python 客户端激活按钮。
这是 HTML 模板:
<ion-toggle id="testaut_useauth_toggle"
ng-change="toggleAuth()"
ng-model="wizard.useauth"
toggle-class="toggle-calm">{{'kWizUseAuth' |
translate}}
</ion-toggle>
我的 appium test.py 代码:
self.click_item("testaut_useauth_toggle")
def click_item(self,id, wait=5):
element = self.driver.find_element_by_id(id)
element.click()
sleep(wait)
我得到的错误:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: unknown error: Element <div class="item item-toggle toggle-small ng-not-empty ng-valid" id="testaut_useauth_toggle" ng-change="toggleAuth()" ng-model="wizard.useauth" toggle-class="toggle-calm" style="">...</div> is not clickable at point (180, 190). Other element would receive the click: <section ng-show="selected" ng-class="{current: selected, done: completed}" class="step current" ng-transclude="" wz-title="2" style="">...</section>
(Session info: chrome=55.0.2883.91)
“其他元素”、“wz-title”基本上是我正在使用的角度向导模板。我的应用程序也在其他屏幕上使用它,我点击按钮没有问题,所以问题出在这个切换开关上(离子实现为复选框)
我尝试过但失败的替代方法:
def tap_item(self,id,wait=5):
print ('Tapping item: {}'.format(id))
element = self.driver.find_element_by_id(id)
#self.driver.execute_script("arguments[0]).click();", element);
self.driver.execute_script("document.getElementById(arguments[0]).click();", id);
这里没有错误,但是没有激活
任何帮助,将不胜感激。
鉴于这是一个网络应用程序,我真的无法获得任何位置。Tap 不起作用,因为该方法未针对 WebView 实现
解决方案
<ion-toggle>
在研究了按钮是如何实现的并且对哪个项目应该是点击的目标进行了一些实验后找到了一个解决方案
最终解决方案:
def tap_toggle(id,wait=Wait.TOGGLE):
element = driver.find_element_by_id(id)
element = element.find_element_by_tag_name('label')
element.click()
sleep(wait)
推荐阅读
- emeditor - 用于切换交替颜色行的宏
- c# - C++ DLL 的函数不在 WPF 中输出文本
- python - 是否可以使用遗传算法随机限制变量数量?
- javascript - 如果是对象,如何检查空值并替换它?
- r - 在 tibble 中寻求变异的帮助
- kendo-ui - 如果 Kendo Grid 中一个单元格的验证失败,如何允许编辑其他单元格?
- sql-server - SSRS:显示数据库中 varbinary 列的图像
- wordpress - Colormag wp 主题页脚自定义
- javascript - 我正在尝试从数组中获取图像以使用 Vue.js 显示。我是在犯语法错误还是错过了什么?
- vue.js - 如何访问包装器 Highcharts vue 的方法?