Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Textarea text missing newlines in Firefox #2956

Closed
lukeis opened this issue Mar 3, 2016 · 4 comments
Closed

Textarea text missing newlines in Firefox #2956

lukeis opened this issue Mar 3, 2016 · 4 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2956

Selenium version: 2.12.1
OS: Windows 7 64-bit
Browser: Firefox
Brower version: 8.0

I'm trying to get the contents of a textarea in an HTML form using webdriver in Python.

I'm getting the text, but all of the newlines are missing.

I'm currently using the following code:

  from selenium import webdriver

  # open the browser and web site
  b = webdriver.Firefox()
  b.get('http://www.example.com')

  # get the textarea element
  textbox = b.find_element_by_name('textbox')

  # print the contents of the textarea
  print(repr(textbox.text))

This prints the representation of a Python unicode string of the textarea's contents
as expected, except all the newlines have been replaced by spaces. Doh!

To test the code on your own, you'll need to replace the URL with one that goes to
a page with text content (try a Wikipedia article's edit page) and 'textbox' with the
name of the text element.

I ran exactly the same code with Chrome instead of Firefox and it works fine.

Reported by Series8217 on 2011-11-28 23:47:05

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The expected behavior for getText() when used on form elements is being discussed in
issue 2922.

Reported by jmleyba on 2011-11-29 17:22:25

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Why was this merged? The other discussion is not about the same behavior/bug. The issue
I reported is specific to the Firefox driver; it works properly on Chrome.

Reported by Series8217 on 2011-11-29 21:50:12

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Have to agree, while probably related, the symptoms here are not discussed in issue
2922.

However, getValue() is working for us with Selenium (RC) 2.14 and FF 8.0.1, (issue
537, comment 2 helped).  Hopefully others finding their way here will have similar
luck there.


For what it's worth, the textarea that tripped us up is neither an input field nor
anything else with an (evident) value parameter, suggesting a use case for getText().
 Similarly, we didn't want more whitespace-trimming, we wanted the rendered text (or
so we thought).

Perhaps "Gets the (whitespace-normalized) value of an input field, textarea or anything
else with a value parameter..."

Reported by fiztlen on 2011-12-13 20:34:14

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:14:17

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@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.
Projects
None yet
Development

No branches or pull requests

1 participant