Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.

TextArea: WebElement.getText() and .getAttribute("value") should be different #2131

lukeis opened this issue Mar 2, 2016 · 4 comments


Copy link

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 2131

Hi all,

With 2.1.0, the far below HTML and WebDriver test case works differently with FF 5
/ IE 9 / HtmlUnit 2.8

getText() a,a,                    -> Correct (should it be "a,")
getAttribute() a,a,               -> Correct (should it be "a,")

getText()                         -> Incorrect
getAttribute() a,a,               -> Correct (should it be "a,")

getText()                         -> Incorrect (due to WebDriver)
getAttribute()                    -> Incorrect (due to HtmlUnit)

Please note that HtmlUnit 2.8 behaves correctly for getText(), but not with getAttribute()
which I will try to fix.

  function init() {
    var s = document.getElementById('s');
    if (s.addEventListener) {
      s.addEventListener('click', handle, false);
    } else if (s.attachEvent) {
      s.attachEvent('onclick', handle);
  function handle(event) {
    myTextArea.value += s.options[s.selectedIndex].value + ',';
</script></head><body onload='init()'>
  <select id='s'>
    <option value='a'>A</option>
    <option id='opb' value='b'>B</option>
    <option value='c'>C</option>
  <textarea id=myTextArea></textarea>

        WebDriver driver = ....;

        WebElement e = driver.findElement("myTextArea"));
        System.out.println("getText() " + e.getText());
        System.out.println("getAttribute() " + e.getAttribute("value"));
        WebClient webClient = ...;
        HtmlPage page = webClient.getPage(url);

        HtmlTextArea e = page.getHtmlElementById("myTextArea");
        System.out.println("getText() " + e.getText());
        System.out.println("getAttribute() " + e.getAttribute("value"));

Reported by on 2011-07-26 10:25:03

Copy link
Member Author

lukeis commented Mar 2, 2016

To make this even more complex, try selecting 'B' in real InternetExplorer and Firefox.

With InternetExplorer:
- User must click on the parent 'select', and then he can click 'b'. In other words,
you can't have the output to 'b,' manually.

With Firefox:
- User can click directly to 'b,' without the need to click the 'select' first.

Should those differences be considered?

Reported by on 2011-07-26 10:34:23

Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by simon.m.stewart on 2011-08-08 07:58:24

  • Labels added: GettingInvolved

Copy link
Member Author

lukeis commented Mar 2, 2016

What is the meaning of the label "GettingInvolved"?

Reported by on 2011-08-08 08:02:48

Copy link
Member Author

lukeis commented Mar 3, 2016


GettingInvolved means this is a good candidate for a bug for someone who wants to start contributing to Selenium to start by looking at, i.e. it's probably not crazily complex, not too huge, and doesn't have much decision-making needed to define the correct answer.

Thanks for the explanation. What about adding a wiki page for the different statii you use for the project's issues?


New tests were added by r18247 and r18252
Currently only IE suffers of this issue.
See TextHandlingTest methods testTextOfATextAreaShouldBeEqualToItsDefaultTextEvenAfterTyping and testTextOfATextAreaShouldBeEqualToItsDefaultTextEvenAfterChangingTheValue

@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

1 participant