Search code examples
javascriptseleniumgettext

getText() returns a blank in Selenium even if the text is not hidden. I also tried JavaScript


I am trying to match the text and select the check box. I am trying to get the text or the innerHTML from the input tag of type checkbox.

I tried getText(); it returns blank, innerHTML, innerText returns null.

I am able to fetch the value, and all the other associated attributes of the tag, but not the text. I tried getting the text by executing the JavaScript code through Selenium, but that is also returning null or blank. How can I fix this?

The text is visible - not hidden.


Solution

  • You could try using getAttribute("textContent") or getAttribute("value")