【问题标题】:Is there a contains class equivalent for css? [duplicate]是否有与 css 等效的包含类? [复制]
【发布时间】:2018-06-04 06:52:43
【问题描述】:

Selenium 中是否包含 css?曾经有:a:contains('Log Out'),但这不再有效。

是否有 css 等价于:

//*[contains(@class, 'dd')]

在https://stackoverflow.com/questions

如何使用 contains 将上述内容编写为 CSS。

【问题讨论】:

    标签: python selenium xpath css-selectors


    【解决方案1】:

    来自Here,

    [attribute*="value"] 选择器用于选择符合以下条件的元素 属性值包含指定的值。

    对于您的问题,您可以使用 *= 这样的代码

    str = 'Logout' 
    driver.find_element_by_css_selector('a[href*="%s"]' % str)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-08
      • 2010-11-30
      • 1970-01-01
      • 2010-10-25
      • 2012-12-01
      • 2019-06-13
      • 2019-12-02
      相关资源
      最近更新 更多