Search code examples
seleniumgettext

Selenium getText behaviour


I have an html file which has to be parsed using selenium. I need to extract a the text contained in a div tag which has an unique id. The original file is as follows:

<div id="debugState" style="display:none"> 
            Model: ModelCode[UK51]
            Features: [S08TL, S0230, S0851, S0428, S01CD, S0879, S01CA, S08SP, S0698,  S01CB, S0548, S08SC, S08TM, S04AK, S01CC, S0801]
            Packages: [S0801]
</div>

The performed command is as follows: selenium.getText("//div[@id='debugState']"); and the result is the empty String (instead of the contained text). Am I doing something wrong or this is the expected result due to the style="display:none"switch.


Solution

  • Have you tried removing the style="display:none" attribute to see what effect it has on your test? According to the JavaDoc this method should do what you need.