【发布时间】: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
Selenium 中是否包含 css?曾经有:a:contains('Log Out'),但这不再有效。
是否有 css 等价于:
//*[contains(@class, 'dd')]
在https://stackoverflow.com/questions
如何使用 contains 将上述内容编写为 CSS。
【问题讨论】:
标签: python selenium xpath css-selectors
来自Here,
[attribute*="value"] 选择器用于选择符合以下条件的元素 属性值包含指定的值。
对于您的问题,您可以使用 *= 这样的代码
str = 'Logout'
driver.find_element_by_css_selector('a[href*="%s"]' % str)
【讨论】: