On Tue, Jun 11, 2013 at 9:48 AM, W. Martin Borgert <[email protected]> wrote:
> On 2013-06-11 09:35, Matteo Landi wrote:
>> 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?
>
> Not sure: How would I fill in a form field found with the xpath
> expression and submit the form? This is the missing bit for me.
I cannot try it right now, but I imagine that you can use xpath to get
the desired form:
>>> form = res.lxml.xpath('//body/div/form')[0]
At this point, with the form in hand you can do whatever you want:
fill fields, submit, etc. Does this make sense?
Matteo
>
> TIA!
>
> --
> 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.