How to get text out of hidden span element

583 views
Skip to first unread message

Dips

unread,
Apr 12, 2011, 12:02:36 PM4/12/11
to Selenium Users
I want to fetch all the text in a hidden <span> element in my Html.

I tried using getText(xpath), but I was not able to get the test out
as the span element is having <stye="display:none">

And, I recently found that it is not possible to take text out of
hidden elements using getText() as per this fix:
http://jira.openqa.org/browse/SEL-650?focusedCommentId=17965&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_17965


Is there any other way I can achieve this? Any Help will be much
appreciated.

Lutfi Dughman

unread,
Apr 13, 2011, 11:27:36 AM4/13/11
to seleniu...@googlegroups.com
this is the first time i heard that selenium cant read text from hidden elements (possibly because i never needed to do such a thing ). but you still have an option with selenium and that is ... javascript.

try using     [var elem= selenium.browserbot.findElement("//SPAN")] to find the element and then [return elem.innerText] or [elem.innerHTML - which would give whole html for elem]

if this doesn't work try document.getElementsByTagName and iterate over all the spans.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Reply all
Reply to author
Forward
0 new messages