You saw it right. find_elements_by_xpath("//ul[contains(@id,'my_id')]//li/text()")
would just fail using Selenium.
We have discussed this functionality in the following discussions
The WebDriver Specification directly refers to:
and none of them precludes a WebElement reference from being a Text Node.
So the bottom line was, as the specification does not specify local end APIs. Client bindings are free to choose an idiomatic API that makes sense for their language. Only the remote end wire protocol is covered here.
@Simon Stewart concluded:
One option might be to serialize a Text node found via executing javascript to be treated as if it were an Element node (that is, assign it an ID and refer to it using that). Should a user attempt to interact with it in a way that doesn't make sense (sending keyboard input, for example) then an error could be returned.
Hence, your first option is the way to go:
options_elements = issn_dropdown.find_elements_by_xpath("//ul[contains(@id,'my_id')]//li")
options = [x.text for x in options_elements]