Feature Requests item #1228021, was opened at 2005-06-27 05:02
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=497985&aid=1228021&group_id=61302

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Priority: 5
Submitted By: rav (ravikaimal)
Assigned to: Nobody/Anonymous (nobody)
Summary: submitting a form using Javascript

Initial Comment:



<html>
        <head>
                <script language="Javascript1.2">
                        function submitForm
(formObj,action){
                            formObj.action = 
action;
                            formObj.method 
= "post";
                            formObj.submit();
                        }
                </script>
        </head>
        <body>
                <A href="sample2.jsp">Click 
Here</A>
                <form name="form1">             
                        UserName<input 
type="text" name="userName"><P>
                        Password<input 
type="password" name="password"><P>
                        <input type="button" 
name="Submit" onclick="submitForm
(this.form,'processForm.jsp');" value="Submit">
                </form>
        </body>
</html>


i have the above code present in my JSP page. How can 
I invoke the onclick event 
and submit the form using JwebUnit? I tried with the 
following code but it is 
not working.

public class SampleTest extends WebTestCase {
         public MonitorStockTest(String name) {
             super(name);
         }
        
         public void setUp(){
         }
         
         public void testFormSubmission(){
                 try{
                        WebConversation 
client = new WebConversation() ;
                        WebResponse 
response = client
                                
        .getResponse
("http://localhost:8080/sample/sample.jsp";) ;
                        WebForm form = 
response.getForms()[0] ;
                        form.setParameter
("userName","asd") ;
                        form.setParameter
("password","asd") ;
                        Button bts[] = 
form.getButtons() ;
                        System.out.println
("Button Name=="+bts[0].getName()) ;
                        ScriptableDelegate 
script = bts[0].getScriptableDelegate() ;
                        ScriptingEngine 
scriptEngine = script.getScriptEngine() ;
                        System.out.println
("$$$$Result"+scriptEngine.performEvent("") );
                        response = 
client.getCurrentPage() ;
                        URL url = 
response.getURL() ;
                        System.out.println("-----
----->Address=="+url.getPath()) ;
                        //assertTextPresent
("login failed") ;
                }catch(SAXException se){
                        se.printStackTrace() ;
                }catch
(java.net.MalformedURLException me){
                        me.printStackTrace() ;
                }catch(IOException ie){
                        ie.printStackTrace() ;
                }
        }
        
        public void tearDown(){
        }
}

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=497985&aid=1228021&group_id=61302


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to