4

I'd like to be able to find links containing: hello, Hello, hEllo, heLlo, etc. So far I'm using find_elements_by_partial_link_text which is casse sensitive:

links = driver.find_elements_by_partial_link_text('hello')
jb.
  • 22,100
  • 16
  • 97
  • 135
Bryan Torres
  • 81
  • 1
  • 3

1 Answers1

7

find_elements_by_partial_link_text() as well as find_elements_by_link_text() are both case sensitive and the behavior cannot be easily changed.

Instead, find links by xpath and apply lower-case() function:

links = driver.find_elements_by_xpath('//a[contains(lower-case(.), "hello")]')

Also see:

Community
  • 1
  • 1
alecxe
  • 441,113
  • 110
  • 1,021
  • 1,148