【问题标题】:Clicking on an "ion-toggle" using appium使用 appium 单击“离子切换”
【发布时间】:2019-03-08 22:33:43
【问题描述】:

我无法使用 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)

“其他元素”,“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 实现该方法

【问题讨论】:

    标签: ionic-framework appium appium-android


    【解决方案1】:

    在研究了&lt;ion-toggle&gt; 按钮的实现方式以及对哪个项目应作为点击目标进行一些实验后找到了解决方案

    最终解决方案:

    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

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 2019-07-03
      • 1970-01-01
      • 2020-06-11
      • 2012-04-13
      • 2017-10-03
      • 2016-10-26
      • 1970-01-01
      • 2010-11-30
      相关资源
      最近更新 更多