[Webtest] setTimeout support in JS/webtest

Jaydeep Ayachit jaydeep_ayachit@persistent.co.in
Wed, 10 Sep 2008 10:42:17 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_0041_01C91331.E553A800
Content-Type: text/plain;
	charset="US-ASCII"
content-transfer-encoding: 7bit

Hello,

 

I am facing issue with recognizing parameter passed to setTimeout() function
in javascript using webtest.

 

setTimeout() functions first parameter is some expression which will get
invoked after the time specified as second parameter. I have a function
called delay as

 

function delay(param)

{

..

..

}

 

Function doSave()

{

     setTimeout("delay(100)", 1000);

}

 

When executed through webtest, I get an exception below. Is setTimeout not
supported through current javascript engine? How can this get working with
webtest?

 

 

[clickLink] ERROR (com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob) -
Caught exception in Window.setTimeout()

[clickLink] ======= EXCEPTION START ========

[clickLink] EcmaError: lineNumber=[1] column=[0] lineSource=[<no source>]
name=[ReferenceError] sourceName=[JavaScriptBackgroundJob]
message=[ReferenceError: "delay" is not defined.
(JavaScriptBackgroundJob#1)]

[clickLink] com.gargoylesoftware.htmlunit.ScriptException: ReferenceError:
"delay" is not defined. (JavaScriptBackgroundJob#1)

[clickLink]     at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAct
ion.run(JavaScriptEngine.java:553)

[clickLink]     at org.mozilla.javascript.Context.call(Context.java:499)

[clickLink]     at
org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)

[clickLink]     at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScript
Engine.java:436)

[clickLink]     at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScript
Engine.java:411)

[clickLink]     at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(Html
Page.java:935)

[clickLink]     at
com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob.run(JavaScriptBackgrou
ndJob.java:114)

[clickLink]     at java.lang.Thread.run(Unknown Source)

[clickLink]     at
com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:130)

[clickLink] Caused by: org.mozilla.javascript.EcmaError: ReferenceError:
"delay" is not defined. (JavaScriptBackgroundJob#1)

[clickLink]     at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)

 

Thanks

Jaydeep

 

 


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

------=_NextPart_000_0041_01C91331.E553A800
Content-Type: text/html;
	charset="US-ASCII"
content-transfer-encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micro=
soft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" xm=
lns=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Courier New";}
p
	{mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Courier New";
	color:windowtext;
	font-weight:normal;
	font-style:normal;
	text-decoration:none none;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span style=3D'f=
ont-size:
11.0pt'>Hello,<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>I am facing issue with recognizing
parameter passed to setTimeout() function in javascript using webtest.<o:p><=
/o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>setTimeout() functions first paramete=
r is
some expression which will get invoked after the time specified as second
parameter. I have a function called delay as<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>function delay(param)<o:p></o:p></spa=
n></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>{<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>..<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>..<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>}<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>Function doSave()<o:p></o:p></span></=
font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>{<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>&nbsp;&nbsp;&nbsp;&nbsp; setTimeout(&=
quot;delay(100)&quot;,
1000);<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>}<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>When executed through webtest, I get=
 an
exception below. Is setTimeout not supported through current javascript engi=
ne?
How can this get working with webtest?<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] ERROR
(com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob) - Caught exception i=
n
Window.setTimeout()<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] =3D=3D=3D=3D=3D=3D=3D EXC=
EPTION START
=3D=3D=3D=3D=3D=3D=3D=3D<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] EcmaError: lineNumber=3D[=
1]
column=3D[0] lineSource=3D[&lt;no source&gt;] name=3D[ReferenceError]
sourceName=3D[JavaScriptBackgroundJob] message=3D[ReferenceError: &quot;dela=
y&quot;
is not defined. (JavaScriptBackgroundJob#1)]<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink]
com.gargoylesoftware.htmlunit.ScriptException: ReferenceError:
&quot;delay&quot; is not defined. (JavaScriptBackgroundJob#1)<o:p></o:p></sp=
an></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAct=
ion.run(JavaScriptEngine.java:553)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
org.mozilla.javascript.Context.call(Context.java:499)<o:p></o:p></span></fon=
t></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)<o:p></o:=
p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScript=
Engine.java:436)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScript=
Engine.java:411)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(Html=
Page.java:935)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
com.gargoylesoftware.htmlunit.JavaScriptBackgroundJob.run(JavaScriptBackgrou=
ndJob.java:114)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
java.lang.Thread.run(Unknown Source)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:130)<o:=
p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] Caused by:
org.mozilla.javascript.EcmaError: ReferenceError: &quot;delay&quot; is not
defined. (JavaScriptBackgroundJob#1)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>[clickLink] &nbsp;&nbsp;&nbsp; at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)=
<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>Thanks<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'>Jaydeep<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dblack face=3D"Courier New"><s=
pan
style=3D'font-size:11.0pt;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span style=3D'=
font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<p>DISCLAIMER=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
This e-mail may contain privileged and confidential information which is the=
 property of Persistent Systems Ltd. It is intended only for the use of the=
 individual or entity to which it is addressed. If you are not the intended=
 recipient, you are not authorized to read, retain, copy, print, distribute=
 or use this message. If you have received this communication in error, plea=
se notify the sender and delete all copies of this message. Persistent Syste=
ms Ltd. does not accept any liability for virus infected mails.</p>
</body>

</html>

------=_NextPart_000_0041_01C91331.E553A800--