mirror of https://github.com/scrapy/scrapy.git
Merge pull request #3153 from virmht/new_bug
[MRG+1] Fixed bug FormRequest.from_response() clickdata ignores input[type=image]
This commit is contained in:
commit
6c3970e672
|
|
@ -170,9 +170,8 @@ 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)]',
|
||||
'descendant::input[re:test(@type, "^(submit|image)$", "i")]'
|
||||
'|descendant::button[not(@type) or re:test(@type, "^submit$", "i")]',
|
||||
namespaces={"re": "http://exslt.org/regular-expressions"})
|
||||
]
|
||||
if not clickables:
|
||||
|
|
|
|||
|
|
@ -544,6 +544,16 @@ class FormRequestTest(RequestTest):
|
|||
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_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)
|
||||
fs = _qs(req)
|
||||
self.assertEqual(fs, {b'i1': [b'i1v'], b'i2': [b'i2v']})
|
||||
|
||||
def test_from_response_multiple_clickdata(self):
|
||||
response = _buildresponse(
|
||||
|
|
|
|||
Loading…
Reference in New Issue