3 messages in com.canoo.lists.webtestRE: [Webtest] Javascript failing| From | Sent On | Attachments |
|---|---|---|
| Brandon Moore | 01 Jul 2003 12:39 | .dat |
| Graham Cunningham | 01 Jul 2003 13:34 | |
| Brandon Moore | 02 Jul 2003 08:33 |
| Subject: | RE: [Webtest] Javascript failing![]() |
|---|---|
| From: | Graham Cunningham (grah...@itwks.com) |
| Date: | 07/01/2003 01:34:00 PM |
| List: | com.canoo.lists.webtest |
I can only assume its cause the link isnt part of the html form and so the submit method isnt recognized. As I am sure you are aware http://httpunit.sourceforge.net/doc/javascript-support.html gives you all the methods that are supported for each html element.
In a similar situation I set my href to call a page global javascript method and this method then did the document.form[0].submit(); Ie
<html> <head> <title>Javascript Test</title> </head> <script language="JavaScript" type="text/JavaScript"> function mySubmit() { document.forms[0].submit(); } </script> <body> <form id="testForm" action="http://www.google.com"> <input name="button" type="SUBMIT"> </form> <a href="javascript:mySubmit();">click</a>
</body> </html>
This worked for me but then I had to mess around a little bit as WebTest hadnt recognized that a submit had occurred. Cheers Graham
Graham Cunningham IT Works Consulting http://itwks.com Natel : +41 79 233 3772
-----Original Message----- From: webt...@gate.canoo.com [mailto:webt...@gate.canoo.com]
Sent: Dienstag, 1. Juli 2003 21:40 To: webt...@gate.canoo.com Subject: [Webtest] Javascript failing
I do have js.jar in my classpath. Javascript attached to forms works fine. onsubmit actions exectute and possibly prevent a clickbutton from taking you anywhere, etc. The exception is thrown inside rhino code (In an object built to be a function objects invoker), so I'm pretty webtest sees rhino on the classpath. No one else has trouble with javascript on links?
I can't figure out what is happening here. Does anyone else see symptoms like this:
I put up a test webpage that looks like this:
<html> <head> <title>Javascript Test</title> </head> <body> <form id="testForm" action="http://www.google.com"> <input name="button" type="SUBMIT"> </form> <a href="javascript:document.forms[0].submit()">click</a>
</body> </html>
My test script invokes the page, uses clicklink with label "click", and crashed:
java.lang.NoClassDefFoundError: com/meterware/httpunit/javascript/JavaScript$Form at inv1.invoke() at org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:498) at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:413) at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191) at org.mozilla.javascript.gen.c1.call(httpunit:0) at org.mozilla.javascript.gen.c1.exec(httpunit) at org.mozilla.javascript.Context.evaluateReader(Context.java:820) at org.mozilla.javascript.Context.evaluateString(Context.java:784) at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.getURLCont ents(JavaScript.java:176) at com.meterware.httpunit.scripting.ScriptableDelegate.evaluateURL(Scriptab leDelegate.java:70) at com.meterware.httpunit.WebWindow.getResource(WebWindow.java:157) at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:117) at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:110) at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:91) at com.meterware.httpunit.WebClient.getResponse(WebClient.java:87) at com.canoo.webtest.steps.request.Target.getResponse(Target.java:263) at com.canoo.webtest.steps.request.Target.gotoTarget(Target.java:219) at com.canoo.webtest.steps.request.Target.gotoTarget(Target.java:186) at com.canoo.webtest.steps.request.ClickLink.doExecute(ClickLink.java:48) at com.canoo.webtest.steps.Step.execute(Step.java:59) at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:32) at com.canoo.webtest.ant.TestSpecificationTask.execute(TestSpecificationTas k.java:55) at org.apache.tools.ant.Task.perform(Task.java:341) at org.apache.tools.ant.Target.execute(Target.java:309) at org.apache.tools.ant.Target.performTasks(Target.java:336) at org.apache.tools.ant.Project.executeTarget(Project.java:1339) at org.apache.tools.ant.Project.executeTargets(Project.java:1255) at org.apache.tools.ant.Main.runBuild(Main.java:609) at org.apache.tools.ant.Main.start(Main.java:196) at org.apache.tools.ant.Main.main(Main.java:235)
Brandon
-----Original Message----- From: webt...@lists.canoo.com [mailto:webt...@lists.canoo.com]On Behalf Of Thakkar, Hetal Sent: Tuesday, July 01, 2003 10:46 AM To: webt...@gate.canoo.com Subject: RE: [Webtest] How to invoke Javascript from canoo?
This might happen because you don't have js.jar in your classpath. Most probably the problem is occurring because one of the jar files is not in your classpath.
As for my case, yes javascript is submitting a form that should make the server change the database.
Hetal
-----Original Message----- From: Brandon Moore [mailto:bmo...@commcode.com] Sent: Monday, June 30, 2003 10:32 AM To: webt...@gate.canoo.com Subject: RE: [Webtest] How to invoke Javascript from canoo?
You could try using the verifyxpath task to compare the contents of the <a> tag with a string, so you can see what the xpath engine canoo uses comes up with. You don't have any trouble following the link if you use an empty label? Any time I try to write a test that follows a link canoo dies with a NoClassDefFound exception inside rhino, missing Javascript$Form from HttpUnit. Any idea why that would be happening? I'm using the latest version.
I would try coding the test in HttpUnit and see if that hits the database. What do you mean the javascript should change the database? Do you mean the javascript should submit a form that should make the server change the database?
Brandon
-----Original Message----- From: webt...@lists.canoo.com [mailto:webt...@lists.canoo.com]On Behalf Of Thakkar, Hetal Sent: Monday, June 30, 2003 12:19 PM To: webt...@gate.canoo.com Subject: RE: [Webtest] How to invoke Javascript from canoo?
Hi Brandon,
When I use "" as label of link then the test runs without any error, but this function "SubmitWithDisclosure" is supposed to update a database, which is not being done, so I don't think it is invoked. When I use "Submit" or " Submit " as label of the link then I get link not found error. The xpath returns "\u00A0Submit\u00A0", which is unicode for "áSubmitá", I tried using that and I get the same link not found error with text "ßSubmitß". I think the problem here is that for some reason when I put "á" in my tests it is changed to "ß" when comparing, so it does not work.
Thanks for your reply, Hetal Y zfj)b? b?m7XAhm+- (Y?b ~y^





.dat