Using Cookies With The HTTPProtocolHandler — PushToTest
Personal tools
You are here: Home Library How To Using Cookies With The HTTPProtocolHandler

Using Cookies With The HTTPProtocolHandler

Shows how to use commands to set custom cookie values when using the TestMaker HTTP protocol handler objects.

The HTTPProtocolHandler uses the jCookie library to manage cookies. It specifically ignores cookie header values.

Here is an example script that passes a cookie to the examples.pushtotest.com site.

from com.pushtotest.tool.protocolhandler import ProtocolHandler, HTTPProtocol
from com.sonalb.net.http.cookie import Cookie

http = ProtocolHandler.getProtocol( "http" ) http.setUrl("http://examples.pushtotest.com") cookie = Cookie("JSESSIONID","C545C2CCAEFE1E08337C37101F3B7168","examples.pushtotest.com", "/" ) http.cookieJar.add( cookie )

#http.setProxyHost("localhost") # Use the Network Monitor #http.setProxyPort(8091)

response = http.connect()

print response print "done"

We also recommend looking at the way cookies are handled in the TestMaker_home/lib/agentbase.py script for additional examples.

Document Actions