单击使用appium的“离子切换”

时间:2019-03-07 20:24:59

标签: ionic-framework appium appium-android

我无法使用appium / python客户端激活<ion-toggle>按钮。

这是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)

基本上,“ other element”,“ 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);

这里没有错误,但没有激活

任何帮助将不胜感激。

鉴于这是一个网络应用程序,所以我真的找不到任何位置。点击不起作用,因为尚未为WebView实现该方法

1 个答案:

答案 0 :(得分:0)

研究了如何实现<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)

也交叉发布在https://github.com/appium/python-client/issues/340