Friday, July 13, 2007

a quick/good example of using the python/twill

Today I have a issue on playing http request by using one of load stress testing tool/appliance, and I suspected that the cookie setting in that appliance is not working properly: 2 cookies were set during the requst, and I expected more cookie to be set. I may ask around the developer for cookie information, but it will take time to find the right resource. Fortunately, the following 9 lines code saves my time:

from twill import get_browser
from twill.commands import *
import sys


b = get_browser()
b.go("http://www.example.com/foo")
show()
print "======="
show_cookies()


the results surprisingly tells me that 8 cookies was set after the request. the next thing is to submit an service request to the vendor, provides my expectation with my findings, then expected solution soon.

No comments: