diff options
author | Gael Pasgrimaud <gael@gawel.org> | 2023-03-09 10:04:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-09 10:04:11 +0100 |
commit | fb46c6e6bbf08ba7e3624c4d83b0b8161cbe4222 (patch) | |
tree | 0da53aa53e31db88f629e1623e4bdb1681ada5a7 /webtest/response.py | |
parent | 8ef619fff5127af55b66c1e6c4f8568f3a29acf4 (diff) | |
parent | b5c16e70e14efc867c089704c3f73fd4cc8eb9d6 (diff) | |
download | webtest-main.tar.gz |
Add TestResponse.clickbutton onclick kwarg
Diffstat (limited to 'webtest/response.py')
-rw-r--r-- | webtest/response.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/webtest/response.py b/webtest/response.py index d2eee6c..fea35aa 100644 --- a/webtest/response.py +++ b/webtest/response.py @@ -159,16 +159,18 @@ class TestResponse(webob.Response): return self.goto(str(found_attrs['uri']), extra_environ=extra_environ) def clickbutton(self, description=None, buttonid=None, href=None, - index=None, verbose=False): + onclick=None, index=None, verbose=False): """ Like :meth:`~webtest.response.TestResponse.click`, except looks for link-like buttons. This kind of button should look like ``<button onclick="...location.href='url'...">``. """ + href_extract = re.compile(onclick) if onclick else re.compile(r"location\.href='(.*?)'") + found_html, found_desc, found_attrs = self._find_element( tag='button', href_attr='onclick', - href_extract=re.compile(r"location\.href='(.*?)'"), + href_extract=href_extract, content=description, id=buttonid, href_pattern=href, |