improvement for lots of multiple-selection forms (now by default the first one is selected - till now it was left unchecked which lead to blank get/post data for the whole form)

This commit is contained in:
Miroslav Stampar 2011-04-01 22:12:24 +00:00
parent c3b54cc222
commit cd7e4f5afc
2 changed files with 5 additions and 2 deletions

View File

@ -2754,7 +2754,7 @@ class HTMLForm:
# Initialisation. Use ParseResponse / ParseFile instead. # Initialisation. Use ParseResponse / ParseFile instead.
def __init__(self, action, method="GET", def __init__(self, action, method="GET",
enctype="application/x-www-form-urlencoded", enctype=None,
name=None, attrs=None, name=None, attrs=None,
request_class=urllib2.Request, request_class=urllib2.Request,
forms=None, labels=None, id_to_labels=None, forms=None, labels=None, id_to_labels=None,
@ -2772,7 +2772,7 @@ class HTMLForm:
""" """
self.action = action self.action = action
self.method = method self.method = method
self.enctype = enctype self.enctype = enctype or "application/x-www-form-urlencoded"
self.name = name self.name = name
if attrs is not None: if attrs is not None:
self.attrs = attrs.copy() self.attrs = attrs.copy()

View File

@ -457,6 +457,9 @@ def __findPageForms():
if forms: if forms:
for form in forms: for form in forms:
for control in form.controls:
if hasattr(control, 'items'):
control.items[0].selected = True
request = form.click() request = form.click()
url = urldecode(request.get_full_url(), kb.pageEncoding) url = urldecode(request.get_full_url(), kb.pageEncoding)
method = request.get_method() method = request.get_method()