Python Selenium search for [object Text]

Home / Uncategorized / Python Selenium search for [object Text]

This is my selenium code below.
sourcesearch = driver.find_element_by_xpath(‘//*[@id="Table_Exame"]/tbody/tr[1]/td/text()[1]’)
And the result is –

selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: The result of the xpath expression "//*[@id="Table_Exame"]/tbody/tr[1]/td/text()[1]" is: [object Text]. It should be an element.

Would there be any ways I can retrieve [object Text] via Selenium? Any kind of help would be appreciated.

Anything other than Xpath weren’t available since the site did not add any tags for the text. Also, sorry for not being able to include the site address since it’s only a member only website.

As your XPath expression terminates with text()[whatever], this resolves to a text container, and not an HTML element (or list of).

Hint: try your XPath expression in the Firefox console with $x(some_xpath_expression) while browsing the page.

Perhaps you should edit your question and add the surrounding HTML excerpt and describe precisely what you expect.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *