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.
  • 23,300
  • 18
  • 98
  • 136
Bryan Torres
  • 81
  • 2
  • 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
  • 462,703
  • 120
  • 1,088
  • 1,195