【问题标题】:android appium click “content-desc” attribute not workingandroid appium单击“content-desc”属性不起作用
【发布时间】:2017-04-06 12:52:00
【问题描述】:

“内容描述”是“提交”,但 click() 似乎不起作用?任何建议,将不胜感激?我也试过tap TouchAction?

(使用 Python)我在尝试单击提交按钮时收到“...元素无法在页面上定位..”错误。

我已经通过可访问性 id 和 xpath 进行了如下尝试:

driver.find_element_by_accessibility_id("提交").click() driver.find_element_by_xpath("//android.view.View/android.widget.Button[@content-desc='Submit ']").click()

还尝试了以下点击触摸动作:

    elem = driver.find_element_by_accessibility_id("Submit ")
    action = TouchAction(driver)
    action.tap(elem).perform()

【问题讨论】:

    标签: android python appium


    【解决方案1】:

    尝试按名称查找元素。

    【讨论】:

      【解决方案2】:

      将以下内容用作 xpath:

      //*[@class = 'android.widget.Button' and @content-desc ='Submit']
      

      希望这会有所帮助,让我知道会发生什么。

      【讨论】:

        【解决方案3】:

        看起来你在 content-desc 标签末尾的空白处输入。我建议改用以下 xpath。

        //android.view.View/android.widget.Button[contains(@content-desc,'Submit')]

        这样,如果空白区域发生变化,那么您的测试以后不会失败

        【讨论】:

          【解决方案4】:

          试试这个,

          els = self.driver.find_element_by_android_uiautomator('new UiSelector().description(Submit)')
          

          【讨论】:

            猜你喜欢
            • 2014-11-20
            • 2020-03-26
            • 2016-11-09
            • 2018-06-04
            • 2014-07-25
            • 2020-02-19
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多