【问题标题】:UISelector Using descriptionContainsUISelector 使用 descriptionContains
【发布时间】:2020-11-11 21:01:15
【问题描述】:

我正在编写自动化脚本,我试图点击基于 content-desc 的元素,我尝试的代码是

app_element = driver.find_element_by_android_uiautomator('new UiSelector().descriptionContains("Subway Surfers")')
app_element.click()

这对我有用

但我想知道是否可以将“Subway Surfers”存储在字符串变量中并在 descriptionContains("Subway Surfers")') 中赋值

 content_description = 'Subway Surfers'
 app_element = driver.find_element_by_android_uiautomator('new UiSelector().descriptionContains(content_description)')

像这样有没有人可以帮助我解决这个问题

【问题讨论】:

    标签: android selenium appium android-uiautomator


    【解决方案1】:

    试试这个:

    content_description = 'Subway Surfers'
    app_element = driver.find_element_by_android_uiautomator('new UiSelector().descriptionContains('+content_description+')')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-13
      • 2019-05-20
      • 2020-02-10
      • 2020-06-15
      • 2021-03-26
      • 1970-01-01
      • 2016-03-23
      相关资源
      最近更新 更多