mirror of https://github.com/scrapy/scrapy.git
Fixed bug FormRequest.from_response() clickdata ignores input[type=image]
This commit is contained in:
parent
acd2b8d43b
commit
d5b7ebcfdc
|
|
@ -170,10 +170,12 @@ def _get_clickable(clickdata, form):
|
|||
"""
|
||||
clickables = [
|
||||
el for el in form.xpath(
|
||||
'descendant::*[(self::input or self::button)'
|
||||
' and re:test(@type, "^submit$", "i")]'
|
||||
'|descendant::button[not(@type)]',
|
||||
namespaces={"re": "http://exslt.org/regular-expressions"})
|
||||
'descendant::*[(self::input or self::button)'
|
||||
' and re:test(@type, "^submit$", "i")]'
|
||||
'|descendant::*[(self::input or self::button)'
|
||||
' and re:test(@type, "^image$", "i")]'
|
||||
'|descendant::button[not(@type)]',
|
||||
namespaces={"re": "http://exslt.org/regular-expressions"})
|
||||
]
|
||||
if not clickables:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -532,6 +532,16 @@ class FormRequestTest(RequestTest):
|
|||
req = self.request_class.from_response(response, dont_click=True)
|
||||
fs = _qs(req)
|
||||
self.assertEqual(fs, {b'i1': [b'i1v']})
|
||||
|
||||
def test_from_response_clickdata_does_not_ignore_image(self):
|
||||
response = _buildresponse(
|
||||
"""<form>
|
||||
<input type="text" name="i1" value="i1v">
|
||||
<input id="image" name="i2" type="image" value="i2v" alt="Login" src="http://my.image.org/1.jpg">
|
||||
</form>""")
|
||||
req = self.request_class.from_response(response, dont_click=True)
|
||||
fs = _qs(req)
|
||||
self.assertEqual(fs, {b'i1': [b'i1v'], b'i2': [b'i2v']})
|
||||
|
||||
def test_from_response_dont_submit_reset_as_input(self):
|
||||
response = _buildresponse(
|
||||
|
|
|
|||
Loading…
Reference in New Issue