Subj : Re: Sample To : Kumar From : Igor Bukanov Date : Wed Apr 14 2004 11:07 am Kumar wrote: > Hi > I have a simple webapplication that has JSP pages and javascript. Some > JavaScript is in the form of included .js file and some inline. > > I want to create a application that > 1. gets the jsp page > 2. There is a form and a submit button in the jsp page whoose onclick > executes javascript function written in the page. This javascript > function calls another javascript function in the included .js file > 3.The onlick of the above button using javascript functions fills > certain params and submits the form. > > Any sample code available. Currently I am not planning to use httpunit > or the likes. Httpunit is ideal for this IM0 and will definitely save your time and efforts. > > Major botllenek is I am not sure how to work with rhino on Javascript > for my requirements. I would suggest to try to run JS file against Rhino shell, http://www.mozilla.org/rhino/shell.html . Copy JS file into a file, say, script.js and create in the same directory onclick.js with code: load("script.js"); var pseudoSubmitButton = {} pseudoSubmitButton.onclick = function(event) { code from onclick handler } var pseudoEvent = {} pseudoSubmitButton.onclick(pseudoEvent); Then run the script in Rhino shell. It should produce a reference or undefined property errors for each browser-specific object like document, window, navigator etc. Try to emulate the objects with pure JS do-nothing objects/functions. Then when you can run the script without any errors you would have a list of additional objects/properties you have to provide for the script to make it work properly. Most likely you will need to parse HTML page into some kind of DOM to feed to the script with proper DOM data but if the page/script are simple enough you can get away with few regexps. Regards, Igor .