-1

I found a problem when using python selenium: Use 'find_element_by_partial_link_text("abc")' .If the "abcd" link still matches in the first place, how can I avoid this problem?

I need to exactly match 'abc', only match 'abc', not 'abcd'. How should I write it?

Andersson
  • 51,635
  • 17
  • 77
  • 129
  • So the first link with "abcd" does match? I don't understand the question – Anand May 01 '18 at 13:44
  • Possible duplicate of [How to use find\_element\_by\_link\_text() properly to not raise NoSuchElementException?](https://stackoverflow.com/questions/6936149/how-to-use-find-element-by-link-text-properly-to-not-raise-nosuchelementexcept) – JeffC May 01 '18 at 19:56

1 Answers1

0

find_element_by_partial_link_text will locate any element with partial match. So the string "abc" will match any string containing this sequence ("qabc", "abckj" and so on).

For exact match use find_element_by_link_text, without the partial.

Guy
  • 46,488
  • 10
  • 44
  • 88