【问题标题】:Selenium - Locating an element based on 2 parts of a single element attributeSelenium - 基于单个元素属性的 2 个部分定位元素
【发布时间】:2017-12-03 18:43:56
【问题描述】:

我想知道是否可以根据属性值的两个部分找到一个元素。例如,如果我有一个id,如下所示:

id="page_x0023_default-firstname_0_contractor"

如何通过搜索 id 的 default-firstName AND contractor 来定位元素?

【问题讨论】:

  • 你提前知道这些元素的值吗?

标签: c# selenium


【解决方案1】:
//*[contains(@id, 'default-firstname')][contains(@id, 'contractor')]

或

//*[contains(@id, 'default-firstname') and contains(@id, 'contractor')]

或css:

[id*='part1'][id*='part2']

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-08
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    相关资源
    最近更新 更多