Issue
I need to get the text of an invisible element, when I try to get it, it gives me nothing when printing it. I ensured that this element is not in a different iframe
. Can any one help me?
Code for getting the element's text:
text = self.dataBrowser.find_element('xpath', '//div[2]/table[1]/tbody/tr[2]/td[2]').text
Solution
As I understand, your element is hidden, i.e. (element is present in the DOM but not visible) and you are trying to extract its text.
For this, you may apply execute_javascript
.
txt = self.dataBrowser.find_element('xpath', '//div[2]/table[1]/tbody/tr[2]/td[2]')
x = driver.execute_script("return arguments[0].innerText", txt)
print(x)
Answered By - Anand Gautam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.