You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of find_by_text uses the following xpath: //*[text()="some text"], which only looks at the first text node within an element. This makes it difficult to query for elements with text split across multiple text nodes.
I think it would be useful to add an alternative that acts more like element.textContent(), querying against all inner text of an element rather than its first text node. This can be done with the following xpath: //*[.="some text"]
It could be called find_by_text_content or find_by_inner_text or something along those lines.
I'm happy to do the implementation and make a pull request if people agree that there's a need / desire for this
The text was updated successfully, but these errors were encountered:
In order to search for a single term in the middle of that content, this is the only XPath selector I've been able to get working in Splinter: //descendant::*/text()[contains(., "spread")].
I'm not an expert in XPath by any means, so it's possible there's a better selector; there were others that worked in the browser dev tools console, but not in Splinter. I tried the selector mentioned in the previous response and it didn't work for my scenario, so I wanted to add my solution to the mix.
The current implementation of
find_by_text
uses the following xpath://*[text()="some text"]
, which only looks at the first text node within an element. This makes it difficult to query for elements with text split across multiple text nodes.I think it would be useful to add an alternative that acts more like
element.textContent()
, querying against all inner text of an element rather than its first text node. This can be done with the following xpath://*[.="some text"]
It could be called
find_by_text_content
orfind_by_inner_text
or something along those lines.I'm happy to do the implementation and make a pull request if people agree that there's a need / desire for this
The text was updated successfully, but these errors were encountered: