如果 HtmlUnit 在内存中存储 cookie,那么 HtmlUnit 会用 cookie 响应服务器吗?
HtmlUnit session 何时终止?当我调用 webclient.closeWindow() 时它会终止吗?
按照。在HtmlUnit文档中,WebClient代表一个浏览器,那么它是代表一个多窗口浏览器(例如IE7,我们可以在其中打开多个选项卡)还是代表一个单窗口浏览器?
如果它代表一个多窗口浏览器,那么 HttpSession 是否像真正的浏览器一样在该 Web 客户端的多个窗口中维护?
最佳答案
不是真正的答案,而是一些提示。
If the HtmlUnit stores cookies in memory then Will HtmlUnit respond the server with cookies?
HtmlUnit 的 cookie 策略是与浏览器兼容的,所以我希望它能够这样做。
When the HtmlUnit session terminates? Will it terminate when i call webclient.closeWindow()?
我对这个不太确定。您是否尝试过测试或调试这个?你看过源代码吗?实际上,我想知道这里的预期行为应该是什么。
As acc. to the HtmlUnit docs, WebClient represents a browser, so does it represent a mutiple-windows browser (like IE7 in which we can open multiple tabs) or a single-window browser?
我认为 WebClient
代表单个选项卡式浏览器。
If it represents a multiple-window browser, then does the HttpSession is maintained accross multiple windows of that webclient like real browsers?
请注意,这种行为在浏览器之间和浏览器版本之间并不一致:IE6、IE7、IE8、Firefox、Chrome,它们的行为(或多或少)不同(请参阅 Cookies in Firefox and Internet Explorer 、 Browsers, processes, cookies and session state 或 Session Cookies, sessionStorage, and IE8 )。所以我不认为“真正的”浏览器有一般规则。
实际上,我认为最好的武器是源代码和调试器。在我看来,这些问题很容易验证。
关于java - HtmlUnit 关于 cookie 和 windows 的疑问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2081260/