From: Dan L. <dl...@ca...> - 2005-03-02 18:45:45
|
Rares, HtmlUnit is a tool for simulating a browser and the API allows you to simulate user actions. As such, you have access to the Web/Client tier, not the business tier. Once the browser reads the page, there is no way to determine the values of an object kept in session. It is possible to simulate this behavior by having the page print the values of the session objects and then doing a compare. Something like: (if your page is jsp) <span id='sessionObjectIdValue'><%= session.getAttribute("objectId") %></span> <form name="myform"><input type="text" name="objectId"></form> then you could use the HtmlUnit API to get the asText() value of the element with Id = 'sessionObjectIdValue' and get the asText() value of the input object in the form by name, and do a compare on them. if you dont want the value to appear in the page, you could use a hidden field or something similar and do the compare on that. There are other similar ways to acheive what you are looking for, but accessing session objects is not possible by the time the data reaches HtmlUnit. dan -----Original Message----- From: htm...@li... [mailto:htm...@li...]On Behalf Of Rares Portan/SPR/RO Sent: Wednesday, March 02, 2005 6:19 AM To: htm...@li... Subject: [Htmlunit-user] htmlunit and sessions Hello, I'm using HtmlUnit for a couple of days to create tests for a web app. To test some of the pages I need to compare the form values with the values of some objects kept in session. I wasn't able to get access to the session, is it possible? How can I do that? Thank you |