You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.
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
The text was updated successfully, but these errors were encountered:
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.
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..."
Originally reported on Google Code with ID 2956
Reported by
Series8217
on 2011-11-28 23:47:05The text was updated successfully, but these errors were encountered: