本文介绍了捕获Selenium的流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我发布的HTTP帖子请求上捕获Selenium对象上的网络流量。虽然返回的JSON字符串具有请求标头,但邮件消息的正文(params)从未被捕获。
I am capturing network traffic on Selenium objects on the HTTP post requests I am making. Although JSON string returned has the request headers, the body(params) of the post message is never captured.
继承我的代码,
host = "localhost"
port = "4444"
browser = r"*pifirefox"
sel = selenium(host, port, browser, url)
.
.
.....Submit action
postRequest = sel.captureNetworkTraffic('json')
postRequest有,
postRequest has,
[{
"statusCode":200,
"method":"POST",
"url":"http://.................",
"bytes":97567,
"start":"2011-12-02T17:42:04.719-0500",
"end":"2011-12-02T17:42:05.044-0500",
"timeInMillis":325,
"requestHeaders":[{
"name":"Host",
"value":"......................."
},{
"name":"User-Agent",
"value":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
},{
"name":"Accept",
"value":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},{
"name":"Accept-Language",
"value":"en-us,en;q=0.5"
},{
"name":"Accept-Encoding",
"value":"gzip, deflate"
},{
"name":"Accept-Charset",
"value":"ISO-8859-1,utf-8;q=0.7,*;q=0.7"
},{
"name":"Proxy-Connection",
"value":"keep-alive"
},{
"name":"Referer",
"value":"...................."
},{
"name":"Cookie",
"value":"...................."
},{
"name":"X-Requested-With",
"value":"XMLHttpRequest"
},{
"name":"X-MicrosoftAjax",
"value":"Delta=true"
},{
"name":"Cache-Control",
"value":"no-cache, no-cache"
},{
"name":"Content-Type",
"value":"application/x-www-form-urlencoded; charset=utf-8"
},{
"name":"Content-Length",
"value":"10734"
},{
"name":"Pragma",
"value":"no-cache"
}],
"responseHeaders":[{
"name":"Date",
"value":"Fri, 02 Dec 2011 22:42:05 GMT"
},{
"name":"Server",
"value":"Microsoft-IIS/6.0"
},{
"name":"Cache-Control",
"value":"private"
},{
"name":"Content-Type",
"value":"text/plain; charset=utf-8"
},{
"name":"Content-Length",
"value":"97567"
},{
"name":"X-Powered-By",
"value":"ASP.NET"
},{
"name":"Via",
"value":"1.1 (jetty)"
},{
"name":"X-AspNet-Version",
"value":"4.0.30319"
}]
}]
我试图模仿Post请求,但没有身体(params)非常不完整。任何建议都将不胜感激。
I am trying to imitate the Post request, but without the body(params), its incomplete. Any suggestions would be greatly appreciated.
干杯,
A
Cheers,A
推荐答案
您无法通过Selenium获取请求或响应正文 - 它只捕获标题。尝试如果你在Windows上运行。
You can't get the request or response body with Selenium - it only captures headers. Try Fiddler2 if you're running on Windows.
这篇关于捕获Selenium的流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!