splinter icon indicating copy to clipboard operation
splinter copied to clipboard

browser.find_link_by_partial_text() doesn't always work

Open SEJeff opened this issue 13 years ago • 8 comments

browser is a splinter.Browser() instance with the firefox driver.

>>> browser.find_link_by_partial_text("admin").text
u'admin DEV'
>>> browser.find_link_by_partial_text("admin DEV")
[]

The html to reproduce this issue

<a class="brand" href="/">
<span>admin</span> <span style="display: inline;" class="env-DEV">DEV</span>
</a>

SEJeff avatar Apr 23 '13 22:04 SEJeff

Please, update the html to include the a tag too.

douglascamata avatar Apr 23 '13 22:04 douglascamata

Sorry it is. I left a bit of it out. Updated the original html

SEJeff avatar Apr 23 '13 23:04 SEJeff

Awkward, Splinter would try to find that using the xpath selector //a[contains(text(), "admin DEV")]. I'll check if another libs with xpath selectors have the same issue.

douglascamata avatar Apr 23 '13 23:04 douglascamata

Can you test that with Chrome and/or zope.testbrowser too, please?

douglascamata avatar Apr 23 '13 23:04 douglascamata

find_link_by_partial_text() will also not find links with line-breaks, e.g.:

<a href="add-employee.html">
  <i class="fa fa-fw fa-user"></i>
  &nbsp;
  Add Employee
</a>

If you change the xpath to this one, find_link_by_partial_text() will work (as I expect at least): //a[contains(., "Add Employee")]

kedder avatar Jan 23 '14 21:01 kedder

The current (wrong) behavior is the same with zope.testbrowser and phantomjs.

kedder avatar Jan 23 '14 21:01 kedder

This problem still happens. Reopening.

andrewsmedina avatar Dec 12 '15 20:12 andrewsmedina

#992 Added tests which confirm this behaviour isn't occurring anymore.

javascript-error avatar Jan 22 '22 02:01 javascript-error