Hi Marc.

Thanks for your answer and sorry for answering so late.


Marc Guillemot wrote:
> 
> Date is an ECMA type and is provided by Rhino. It surely relies directly
> on java Date. Neither Webtest nor HtmlUnit currently provide ways to
> fake it.
> 

Well, they may should. Now we did a workaround: You could use a
GET-Parameter with a date representation (e.g.
http://url.de/calendar/show?month=01/2008). This parameter is looped through
the Grails controller into the gsp and there we set a javascript variable
like
    <g:if test="${month}">
        <g:javascript>var month = "${month}"</g:javascript>  
    </g:if>
If this javascript variable is defined we decide which YUI calendar
constructor we use (with or without config map). This works - but is ugly!

It's ugly, because we have to fumble the new date through the whole webapp.
And this seems to be no smell in the testdriven way, where this would mean
that we _should_ open our webapp to deal with this kind of interaction like
setting the date.

Testdrivenly spoken I would like to change my environment (the browser or
the OS; here: Webtest) to see how my code behave. Therfore I would recommend
a feature request for changing browser's time and date through
Webtest/Htmlunit. What do you think about this?


Marc Guillemot wrote:
> 
> Nevertheless you can do it by injecting javascript code just like what
> you could do in a normal browser. For instance with someting like this:
> 
> var originalDate = window.Date;
> window.Date = function() {
>       return new originalDate(2007, 0, 15)
> }
> 
> var now = new Date();
> alert(now.toLocaleString())
> 

Hm, with this solution I can't see how to change the date through my
webtest. See our "solution" above for further info.


Marc Guillemot wrote:
> 
> PS: when comes the next Grails-WebTest plugin release?
> 

When I learned to live with less than five hours sleep ;-)

   Bernd

Bernd Schiffer wrote:
> Hi.
> 
> What's the prefered way to set the date the internal browser webtest is
> using?
> 
> More concret: I have a website with a javascript calendar which showes the
> actual month depending on the browsers time which is the OS's time. If I
> change the OS's time, the calendar shows the corresponding month. The
> strategy I figured out now is, that I could change webtest's internal
> browser's time, so the calendar would show the corresponding month and I
> could test that it is the correct month. How can I do that or is there
> another prefered strategy to use here?
> 
>   Bernd
> 
> P.S.: I'm using the Grails and Grails' Webtest Plugin.


_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest



-- 
View this message in context: 
http://www.nabble.com/Set-date-to-browse-with-different-date-settings-tp15870856p15976508.html
Sent from the WebTest mailing list archive at Nabble.com.

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to