[ptt-users] get and post together
Thieme.Geoff
Geoff.Thieme at we-energies.com
Fri Jan 5 12:40:44 PST 2007
I needed to do a self.get and self.post at the same time to a web page
(needed to post data and add ?url=actionAddPaymentRequest to the url). I
couldn't find this covered in the documentation anywhere. When I
recorded my functional test using the proxy server, it did not create a
working functional test.
The results from recording were:
self.params = [ [ '''url''', '''startWePaymentRequest''' ],[
'''form1''', data1 ],[ '''form2''', data2 ] ]
self.get( '''http://server/HttpController''', self.params)
self.params = [ [ '''url''', '''actionAddPaymentRequest''' ],[
'''form1''', data1 ],[ '''form2''', data2 ] ]
self.post( '''http://server/HttpController''', self.params)
My app uses the servlet named HttpController to do most of the work. You
pass ?url=pagename to tell HttpController what to do (e.g.
https://server/HttpController?url=startWePaymentRequest). When I ran the
code above, the results were that startWePaymentRequest got loaded twice
and actionAddPaymentRequest never get loaded.
Here were my changes to get the test to work:
self.params = [ [ '''url''', '''startWePaymentRequest''' ],[
'''form1''', data1 ],[ '''form2''', data2 ] ]
self.get( '''http://server/HttpController''', self.params)
# Set the get params for the next post by first sending them to
a dummy page
self.params = [ [ '''url''', '''actionAddPaymentRequest''' ] ]
self.get( '''http://server/images/calendar.gif''', self.params)
self.params = [ [ '''form1''', data1 ],[ '''form2''', data2 ] ]
self.post( '''http://server/HttpController''', self.params)
By loading calendar.gif with url=actionAddPaymentRequest as the get
param, something in the self object must get setup. This setup is then
used by the next self.post to send ?url=actionAddPaymentRequest in the
url and load the correct page.
This was tricky to figure out, but it is a work-around that allows
running a functional test with my app. Hopefully this will be useful to
someone it the future.
-Geoff Thieme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cake.pushtotest.com/pipermail/users/attachments/20070105/e088df0a/attachment.htm
More information about the Users
mailing list