[Webtest] Webtest - Ant integration

Subir Bhaumik Subir Bhaumik" <subir_05@rediffmail.com
12 Sep 2007 14:03:39 -0000


 This is a multipart mime message


--Next_1189605819---0-202.137.237.207-27117
Content-type: text/plain;
	charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

  =0AHi Andrew,=0AThanks for your quick reply. Actually i have already test=
ed our application writing build.xml. But i want to run those scripts writi=
ng java code using ant and canoo webtest api. The code will take the webtes=
t script(only the test script excluding the ant tasks or ant properties) as=
 input and run that using ant programmatically.=0A=0AIhave tried like below=
:=0A=0AProject p2 =3D new Project();=0A			p2.setName("webtest_proj");=0A			=
p2.setDefault("web_test_task") ;=0A			p2.setBasedir(".");=0A			=0A			Config=
uration config =3D new Configuration();=0A			config.setHaltonerror(false);=
=0A			config.setHaltonfailure(false);=0A			config.setHost("localhost");=0A	=
		config.setPort(8080);=0A			config.setProtocol("http");=0A			config.setRes=
ultfile("results.xml");=0A			config.setResultpath(new File("D:\\subir\\Down=
loads\\webtest"));=0A			config.setSaveresponse(true);=0A			config.setSummar=
y(true);=0A			=0A			Ant ant =3D new Ant();=0A			//ant.setProject(p2);=0A			=
ant.setTaskName("test");=0A			ant.setAntfile("D:\\subir\\Downloads\\webtest=
\\bkmmodulemod.xml");=0A			WebtestTask webtask =3D new WebtestTask();=0A			=
webtask.setProject(p2);=0A			webtask.setName("web_test_task");=0A			webtask=
.setTaskName("web_test_task");=0A			webtask.addConfig(config);=0A			webtask=
.addTask(ant);=0A			=0A			Target web_test_task =3D new Target();=0A			web_t=
est_task.setName("web_test_task");=0A			web_test_task.addTask(webtask);=0A	=
		=0A			web_test_task.execute();=0A			p2.addTarget(web_test_task);=0A=0A=0A=
Thanks=0A=0ASubir =0A=0AOn Tue, 11 Sep 2007 Andrew Sickorsky wrote :=0A>Hel=
lo, Subir!=0A>in our company we used the following:=0A>part of build.xml:=
=0A><target name=3D"test-web">=0A>        <taskdef file=3D"${test-web.dir}/=
properties/webtest-tasks.properties">=0A>            <classpath refid=3D"co=
mpile.test.classpath"/>=0A>        </taskdef>=0A>        <ant antfile=3D"${=
test-web.dir}/use-cases/web-tests.xml"/>=0A>    </target>=0A>=0A>where web-=
test.xml is a common Canoo WebTest's file, and compile.test.classpath is AN=
T path structure with reference to directory with Webtest's library JARs  (=
in our case they are:=0A>activation-1.1.jar=0A>classpath.xml=0A>commons-htt=
pclient-3.0.1.jar=0A>commons-io-1.3.1.jar=0A>dom4j-1.6.1.jar=0A>fontbox-0.1=
.0-dev-patched-20060622.jar=0A>groovy-all-1.0.jar=0A>htmlunit-1.13.jar=0A>j=
axen-1.1.1.jar=0A>js-1.6R5.jar=0A>mail-1.4.jar=0A>nekohtml-0.9.5.jar=0A>oro=
-2.0.6.jar=0A>pdfbox-0.7.3-dev-log4j-20060612.jar=0A>poi-3.0.1-FINAL.jar=0A=
>webtest.jar=0A>2webtest_T.jar)=0A>=0A>may be this helps.=0A>=0A>Cheers,=0A=
>Andrew=0A>>=0A>>  Hi,=0A>>I'm using Canoo WebTest tool for automated testi=
ng of our application. I have already tested our application using this too=
l running the script from command line.=0A>>=0A>>Now, i want to run test wr=
iting java code using ant and canoo webtest api taking the test script file=
 as input.=0A>>=0A>>Can anybody provide me sample code to start with for th=
at or any reference.=0A>>=0A>>Help me Please......=0A>>=0A>>Thanks && Regar=
ds...............=0A>>=0A>>Subir=0A>>=0A>>=0A>>=0A>>travel_rediff_signature=
_578x38.jpg <http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff=
.com/signature-home.htm/1050715198@Middle5/1436607_1430041/1436150/1?PARTNE=
R=3D3&OAS_QUERY=3Dnull%20target=3Dnew%20> =0A>>=0A>=0A
--Next_1189605819---0-202.137.237.207-27117
Content-type: text/html;
	charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<P>=0A&nbsp; <BR>=0AHi Andrew,<BR>=0AThanks for your quick reply. Actually =
i have already tested our application writing build.xml. But i want to run =
those scripts writing java code using ant and canoo webtest api. The code w=
ill take the webtest script(only the test script excluding the ant tasks or=
 ant properties) as input and run that using ant programmatically.<BR>=0A<B=
R>=0AIhave tried like below:<BR>=0A<BR>=0AProject p2 =3D new Project();<BR>=
=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;p2.setName(&=
quot;webtest_proj&quot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nb=
sp; &nbsp; &nbsp;p2.setDefault(&quot;web_test_task&quot;) ;<BR>=0A&nbsp; &n=
bsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;p2.setBasedir(&quot;.&qu=
ot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<BR=
>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;Configurati=
on config =3D new Configuration();<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; =
&nbsp;&nbsp; &nbsp; &nbsp;config.setHaltonerror(false);<BR>=0A&nbsp; &nbsp;=
 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;config.setHaltonfailure(fals=
e);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;confi=
g.setHost(&quot;localhost&quot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &=
nbsp;&nbsp; &nbsp; &nbsp;config.setPort(8080);<BR>=0A&nbsp; &nbsp; &nbsp;&n=
bsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;config.setProtocol(&quot;http&quot;);=
<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;config.s=
etResultfile(&quot;results.xml&quot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nb=
sp; &nbsp;&nbsp; &nbsp; &nbsp;config.setResultpath(new File(&quot;D:\\subir=
\\Downloads\\webtest&quot;));<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp=
;&nbsp; &nbsp; &nbsp;config.setSaveresponse(true);<BR>=0A&nbsp; &nbsp; &nbs=
p;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;config.setSummary(true);<BR>=0A&n=
bsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<BR>=0A&nbsp; &nb=
sp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;Ant ant =3D new Ant();<BR=
>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;//ant.setPr=
oject(p2);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbs=
p;ant.setTaskName(&quot;test&quot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp=
; &nbsp;&nbsp; &nbsp; &nbsp;ant.setAntfile(&quot;D:\\subir\\Downloads\\webt=
est\\bkmmodulemod.xml&quot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp=
;&nbsp; &nbsp; &nbsp;WebtestTask webtask =3D new WebtestTask();<BR>=0A&nbsp=
; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;webtask.setProject(p=
2);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;webta=
sk.setName(&quot;web_test_task&quot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nb=
sp; &nbsp;&nbsp; &nbsp; &nbsp;webtask.setTaskName(&quot;web_test_task&quot;=
);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;webtas=
k.addConfig(config);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &=
nbsp; &nbsp;webtask.addTask(ant);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &=
nbsp;&nbsp; &nbsp; &nbsp;<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nb=
sp; &nbsp; &nbsp;Target web_test_task =3D new Target();<BR>=0A&nbsp; &nbsp;=
 &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;web_test_task.setName(&quot;=
web_test_task&quot;);<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; =
&nbsp; &nbsp;web_test_task.addTask(webtask);<BR>=0A&nbsp; &nbsp; &nbsp;&nbs=
p; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<BR>=0A&nbsp; &nbsp; &nbsp;&nbsp; &nbsp=
; &nbsp;&nbsp; &nbsp; &nbsp;web_test_task.execute();<BR>=0A&nbsp; &nbsp; &n=
bsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;p2.addTarget(web_test_task);<BR=
>=0A<BR>=0A<BR>=0AThanks<BR>=0A<BR>=0ASubir <BR>=0A<BR>=0AOn Tue, 11 Sep 20=
07 Andrew Sickorsky wrote :<BR>=0A&gt;Hello, Subir!<BR>=0A&gt;in our compan=
y we used the following:<BR>=0A&gt;part of build.xml:<BR>=0A&gt;&lt;target =
name=3D&quot;test-web&quot;&gt;<BR>=0A&gt;&nbsp; &nbsp; &nbsp; &nbsp; &lt;t=
askdef file=3D&quot;${test-web.dir}/properties/webtest-tasks.properties&quo=
t;&gt;<BR>=0A&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;classpath re=
fid=3D&quot;compile.test.classpath&quot;/&gt;<BR>=0A&gt;&nbsp; &nbsp; &nbsp=
; &nbsp; &lt;/taskdef&gt;<BR>=0A&gt;&nbsp; &nbsp; &nbsp; &nbsp; &lt;ant ant=
file=3D&quot;${test-web.dir}/use-cases/web-tests.xml&quot;/&gt;<BR>=0A&gt;&=
nbsp; &nbsp; &lt;/target&gt;<BR>=0A&gt;<BR>=0A&gt;where web-test.xml is a c=
ommon Canoo WebTest's file, and compile.test.classpath is ANT path structur=
e with reference to directory with Webtest's library JARs&nbsp; (in our cas=
e they are:<BR>=0A&gt;activation-1.1.jar<BR>=0A&gt;classpath.xml<BR>=0A&gt;=
commons-httpclient-3.0.1.jar<BR>=0A&gt;commons-io-1.3.1.jar<BR>=0A&gt;dom4j=
-1.6.1.jar<BR>=0A&gt;fontbox-0.1.0-dev-patched-20060622.jar<BR>=0A&gt;groov=
y-all-1.0.jar<BR>=0A&gt;htmlunit-1.13.jar<BR>=0A&gt;jaxen-1.1.1.jar<BR>=0A&=
gt;js-1.6R5.jar<BR>=0A&gt;mail-1.4.jar<BR>=0A&gt;nekohtml-0.9.5.jar<BR>=0A&=
gt;oro-2.0.6.jar<BR>=0A&gt;pdfbox-0.7.3-dev-log4j-20060612.jar<BR>=0A&gt;po=
i-3.0.1-FINAL.jar<BR>=0A&gt;webtest.jar<BR>=0A&gt;2webtest_T.jar)<BR>=0A&gt=
;<BR>=0A&gt;may be this helps.<BR>=0A&gt;<BR>=0A&gt;Cheers,<BR>=0A&gt;Andre=
w<BR>=0A&gt;&gt;<BR>=0A&gt;&gt;&nbsp; Hi,<BR>=0A&gt;&gt;I'm using Canoo Web=
Test tool for automated testing of our application. I have already tested o=
ur application using this tool running the script from command line.<BR>=0A=
&gt;&gt;<BR>=0A&gt;&gt;Now, i want to run test writing java code using ant =
and canoo webtest api taking the test script file as input.<BR>=0A&gt;&gt;<=
BR>=0A&gt;&gt;Can anybody provide me sample code to start with for that or =
any reference.<BR>=0A&gt;&gt;<BR>=0A&gt;&gt;Help me Please......<BR>=0A&gt;=
&gt;<BR>=0A&gt;&gt;Thanks &amp;&amp; Regards...............<BR>=0A&gt;&gt;<=
BR>=0A&gt;&gt;Subir<BR>=0A&gt;&gt;<BR>=0A&gt;&gt;<BR>=0A&gt;&gt;<BR>=0A&gt;=
&gt;travel_rediff_signature_578x38.jpg &lt;http://adworks.rediff.com/cgi-bi=
n/AdWorks/click.cgi/www.rediff.com/signature-home.htm/1050715198@Middle5/14=
36607_1430041/1436150/1?PARTNER=3D3&amp;OAS_QUERY=3Dnull%20target=3Dnew%20&=
gt; <BR>=0A&gt;&gt;<BR>=0A&gt;<BR>=0A=0A</P>=0A<br><br>=0A<Table border=3D0=
 Width=3D644 Height=3D57 cellspacing=3D0 cellpadding=3D0 style=3D'font-fami=
ly:Verdana;font-size:11px;line-height:15px;'><TR><td><a href=3D'http://adwo=
rks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/=
1050715198@Middle5/1436607_1430041/1436146/1?PARTNER=3D3&OAS_QUERY=3Dnull t=
arget=3Dnew '><img src =3Dhttp://imadworks.rediff.com/cgi-bin/AdWorks/adima=
ge.cgi/1436607_1430041/creative_1436146.jpg  alt=3D'sbi_rediff_signaturelin=
e_578x38.jpg'  border=3D0></a></td></TR></Table>
--Next_1189605819---0-202.137.237.207-27117--