Closed vkepin closed 7 years ago
According to the Selenium WebElement API docs, the getText method gets "the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace."
By that description, I think we would have to stay with innerText. What do you think?
Note if you need the textContent calling WebElement.getAttribute("textContent") should work.
The reason of that change is that our team faced issue with getText() from textarea element, unlike other WebDrivers, JBrowser returns empty String for this.
As about visibility of text, I guess according JBrowser implementation of ElementServer.getText() : 558: if ((Boolean) node.eval(IS_VISIBLE)) -> check for visibility 560: return text instanceof String ? ((String) text).trim() : ""; -> will remove leading or trailing whitespaces
That's why I propose this update
If you want to make the getText method contain a conditional, such as if(textarea){ return textContent; } return innerText;
I'm ok with that. There are at least several special cases like that already.
The check that exists for whether the element is visible won't help when when, e.g., a hidden span is inside a div of text, and you ask for the text of the div.
Updated
Looks good. Thanks for working on this and contributing it!
Fyi, recent changes are released in v0.17.8
Change JSObject attribute 'innerText' to 'textContent' according w3c standart https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent