0

Is there a css contains in Selenium? There used to be: a:contains('Log Out') but this no longer works.

Is there a css equivlent for:

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

on https://stackoverflow.com/questions

How would I write the above as a CSS using contains.

1 Answers1

1

From Here,

The [attribute*="value"] selector is used to select elements whose attribute value contains a specified value.

for your question, You can use like this code with *=

str = 'Logout' 
driver.find_element_by_css_selector('a[href*="%s"]' % str)
parik
  • 2,313
  • 12
  • 39
  • 67