Is there a way to fill out textarea that is part of form using mechanize module for Python?
The forms
reference has a couple of examples of filling text controls in response
objects.
A relevant quote:
# The kind argument can also take values "multilist", "singlelist", "text",
# "clickable" and "file":
# find first control that will accept text, and scribble in it
form.set_value("rhubarb rhubarb", kind="text", nr=0)
The kind
argument can be used with the form.find_control()
and form.set_value()
methods to locate "text"
controls.
Digging a little into the mechanize _form.py
source, We have an explanation. Mechanize TextControl
covers (among others) the TEXTAREA
form element.
#---------------------------------------------------
class TextControl(ScalarControl):
"""Textual input control.
Covers:
INPUT/TEXT
INPUT/PASSWORD
INPUT/HIDDEN
TEXTAREA
"""
def __init__(self, type, name, attrs, index=None):
ScalarControl.__init__(self, type, name, attrs, index)
if self.type == "hidden": self.readonly = True
if self._value is None:
self._value = ""
def is_of_kind(self, kind): return kind == "text"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With