On Mon, Jun 10, 2013 at 9:39 PM, W. Martin Borgert <[email protected]> wrote:
> On 2013-06-10 21:32, Matteo Landi wrote:
>> I played with webtest and I have to say that it is very powerful: I
>> used it to test the endpoints of a REST API (with standard HTTP status
>> codes, file uploads and stuff like that..) and it worked like a charm.
>> Sometimes the documentation leaves something to be desired but in the
>> end it is I have always found the solution to my problems.
>
> Maybe you found a solution for this problem: I took a look into
> webtest and found that I can reference forms via their id or
> their positional number (like twill). I would have to reference
> a form in some cases by their name, or better by arbitrary xpath
> expressions. Is this possible with webtest?
It should be possible [1]; have a look at the following snippet:
>>> from webtest import TestRequest
>>> from webtest import TestResponse
>>> res = TestResponse(content_type='text/html', body=b'''
... <html><body><div id="content">hey!</div></body>''')
>>> res.request = TestRequest.blank('/')
>>> res.html
<html><body><div id="content">hey!</div></body></html>
>>> res.html.__class__
<class 'BeautifulSoup.BeautifulSoup'>
>>> res.lxml
<Element html at ...>
>>> res.lxml.xpath('//body/div')[0].text
'hey!'
Does this solve your issue?
Cheers,
Matteo
[1] http://webtest.pythonpaste.org/en/1.4.3/
>
> (We go a little bit off-topic in respect to web.py itself, OTOH
> most web.py developers have to unittest their apps...)
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/webpy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.