• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clicking button in Httpunit

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Iam testing a web application. in that my testcase is to test the login to the application.
iam able to open the URL of the application and able to enter the Username and Password using Code.
Iam getting Nullpointer Exception Error when i try to click in the Sigh In button to login to the application.
can any one help me how to do this
here is my code
WebForm wf=jdoc.getForms()[0];// to get the details of the current form
SubmitButton saveButton = wf.getSubmitButton( "Sign In", "Sign In" );// for clicking the submit button
wf.submit(saveButton);
Regards,
Ranganath
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you explain where the NullPointerException originates from (a stack trace would be nice)?
 
Devalapelly Ranganath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thank you for your replay
This is the stack trace iam getting.
TypeError: undefined is not a function. (httpunit; line 80)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:590)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:550)
at org.mozilla.javascript.NativeGlobal.typeError1(NativeGlobal.java:560)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1184)
at org.mozilla.javascript.gen.c118.call(httpunit:80)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2179)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:58)
at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEvent(JavaScript.java:162)
at com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDelegate.java:55)
at com.meterware.httpunit.WebRequestSource.submitRequest(WebRequestSource.java:224)
at com.meterware.httpunit.WebForm.doFormSubmit(WebForm.java:75)
at com.meterware.httpunit.WebForm.submit(WebForm.java:67)
at MainHttpunit.FirstTestcase.ToRun(FirstTestcase.java:43)
at MainHttpunit.FirstTestcase.main(FirstTestcase.java:20)
Error: com.meterware.httpunit.ScriptException: Event 'if (window.msp_submit) return msp_submit(this); else return true;' failed: TypeError: undefined is not a function. (httpunit; line 80)

I hope iam getting the above exception when WebForm.Submit(SubmitButton) is used
Regards,
Ranganath
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Now could you post the piece of HTML and the JavaScript code being executed on form submit?
 
Devalapelly Ranganath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the HTML code
<input type="submit" value="Sign In" class="button button96px">
Regards,
Ranganath
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd need to see the <form ... onsubmit="..."> tag as well as any JavaScript functions that the 'onsubmit' attribute calls. In the meanwhile, you could also try browsing the HttpUnit website (mailing list archives, list of supported JavaScript features, FAQ) to see whether there is a mention about your particular JavaScript error.
 
Devalapelly Ranganath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rick,
Here is the code which u was asking about
<form name="LoginForm" method="POST" action="/panama/common/login/postLogin.do" onsubmit="if (window.msp_submit) return msp_submit(this); else return true;">
it is very urgent can u replay me as soon as possible if Httpunit doesnot support this method. what is the alternative
Thanks,
ranganath
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "msp_submit"? I know it's not a standard property of the window object, and it seems that it's not the name of your <form> either, and since your calling "msp_submit(this)", I suspect it must be a function? Does the JavaScript in question work with Mozilla web browser?
 
Devalapelly Ranganath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rick,
I could not find any function like msp_submit(). is there any other way to do click the button
Regards,
Ranganath
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, your HTML includes a JavaScript call for a function named "msp_submit" so you'll have to ask whoever wrote that code...
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also submit the form by calling mySubmitButton.click(), but you should be encountering the exact same problem with the JavaScript.
 
Did you miss me? Did you miss this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic