From 937277e8598bd3f62642d4d8267cec2defcead7c Mon Sep 17 00:00:00 2001 From: Olaf Dietsche Date: Sun, 12 Jul 2015 13:37:28 +0200 Subject: [PATCH] Make sure value attribute values are set. --- scrapy/http/request/form.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scrapy/http/request/form.py b/scrapy/http/request/form.py index 1920cefe1..a12a2fd07 100644 --- a/scrapy/http/request/form.py +++ b/scrapy/http/request/form.py @@ -159,7 +159,7 @@ def _get_clickable(clickdata, form): # If we don't have clickdata, we just use the first clickable element if clickdata is None: el = clickables[0] - return (el.get('name'), el.get('value')) + return (el.get('name'), el.get('value') or '') # If clickdata is given, we compare it to the clickable elements to find a # match. We first look to see if the number is specified in clickdata, @@ -171,7 +171,7 @@ def _get_clickable(clickdata, form): except IndexError: pass else: - return (el.get('name'), el.get('value')) + return (el.get('name'), el.get('value') or '') # We didn't find it, so now we build an XPath expression out of the other # arguments, because they can be used as such @@ -179,7 +179,7 @@ def _get_clickable(clickdata, form): u''.join(u'[@%s="%s"]' % c for c in six.iteritems(clickdata)) el = form.xpath(xpath) if len(el) == 1: - return (el[0].get('name'), el[0].get('value')) + return (el[0].get('name'), el[0].get('value') or '') elif len(el) > 1: raise ValueError("Multiple elements found (%r) matching the criteria " "in clickdata: %r" % (el, clickdata))