Quoting "Matteo Landi" <[email protected]>:
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?
Almost :~) I fiddled a little bit with it and came up with this:
# in my app, forms have unique names, but seldomly ids
def get_form_by_name(resp, name):
return webtest.Form(resp, lxml.etree.tostring(
resp.lxml.xpath("//form[@name='%s']" % name)[0]))
resp = app.get("/")
form = get_form_by_name(resp, "myform")
form["field"] = "whatever"
resp = form.submit()
Seems to work... Many thanks for the help!
--
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.