[Webtest] RE: WebTest clickLink fail

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Fri, 11 May 2007 13:34:34 +0200


Does it mean that your application now relies on the Referer header
field? In such a case give this won't work with HtmlUnit-1.11 but would
work if you take an HtmlUnit snapshot.

I don't understand "Method is GET instead of HTTP". HTTP is not a
method, but a protocol.

Marc.

Francisco Javier Martin Gutierrez wrote:
> Hello all,
> 
> Perhaps my question was wrong formulated. Webtest click the link or press
> the button properly but the obtained response is not the expected response.
> Webtest says that it can find the target and it does the action.
> 
> Two days before I pressed a button for reaching the next page and I reached
> it. But now the application has changed and the next page obtained is an
> error page. I am analyzing server response for further details but the
> unique difference is that I haven't configured in header the parameters
> REFERER and Request Method is GET instead of HTTP. So it can't be the
> problem because REFERER parameter is not set in server (the application runs
> in Oracle).
> 
> There are not expected dialogs so I think that I don't need to configure it
> (I did it in other situations).
> 
> I only need to pass the next steps:
> 
> <clickButton	description="Click the submit button: Efectuar cambios de
> estado"
> 	name="efectuarCambiosEstado"  label="Efectuar cambios de estado"
> x="45" y="13" />
> 		<verifyText		description="Texto presente: En caso
> afirmativo, indique el motivo de cierre. "
> 			text="En caso afirmativo, indique el motivo de
> cierre." />
> 
> But when I click the button the page loaded is not the expected page because
> server sends an error page and it doesn't happens when I do it with
> iexplore. It is an strange success. 
> 
> The webtest response is: 
> 
> [clickButton]  INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
> clickButton "Click the submit button: Efectuar cam
> bios de estado" (111/211)
> [clickButton]  INFO (com.canoo.webtest.steps.request.AbstractTargetAction) -
> -> gotoTarget by clickButton with name: efe
> ctuarCambiosEstado
> [clickButton]  INFO (com.canoo.webtest.steps.request.ClickButton) - ->
> findTarget(by input): name=efectuarCambiosEstado
> value=Efectuar cambios de estado
> [clickButton]  INFO (com.canoo.webtest.steps.request.ClickButton) - ->
> findTarget(by input): name=efectuarCambiosEstado
> value=Efectuar cambios de estado
> [clickButton]  WARN (com.gargoylesoftware.htmlunit.html.HtmlPage) - Expected
> content type of text/javascript or applicat
> ion/x-javascript for remotely loaded javascript element
> http://espinete:7783/sauss/js/sauss.js but got [application/octe
> t-stream]
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of
> window changed to http://espinete:7783/saus
> s/HistoriaSocialValorPrestHS.do (text/html)
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of
> current window changed, it will become curr
> ent response
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Current
> form set to none
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Current
> response now: http://espinete:7783/sauss/Histo
> riaSocialValorPrestHS.do
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of
> window changed to http://espinete:7783/saus
> s/HistoriaSocialValorPrestHS.do (text/html)
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Content of
> current window changed, it will become curr
> ent response
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Current
> form set to none
> [clickButton]  INFO (com.canoo.webtest.engine.WebClientContext) - Current
> response now: http://espinete:7783/sauss/Histo
> riaSocialValorPrestHS.do
> [verifyText]  INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
> verifyText "Texto presente: En caso afirmativo, ind
> ique el motivo de cierre. " (112/211)
> ....
> INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: R_1515.
>  INFO (com.canoo.webtest.steps.Step) - Exception thrown from this class:
> com.canoo.webtest.engine.StepFailedException
>  INFO (com.canoo.webtest.steps.Step) - Message was: Step[verifyText "Texto
> presente: En caso afirmativo, indique el moti
> vo de cierre. " (112/211)]: Text not found in page. Expected <En caso
> afirmativo, indique el motivo de cierre.>
> Adding reference: ant.PropertyHelper
>  INFO (com.canoo.webtest.ant.WebtestTask) - Finished executing webtest
> "PruebaPc001" (C:\Webtest\SAUSS\PruebaPc001.xml:4
> 4: )
>  INFO (com.canoo.webtest.ant.WebtestTask) - Test report successfully
> created.
> 
> BUILD FAILED
> C:\Webtest\SAUSS\PruebaPc001.xml:44: Canoo Webtest: R_1515.
> Test failed.
> Test step steps (C:\Webtest\SAUSS\PruebaPc001.xml:47: ) null failed with
> message "Step[verifyText "Texto presente: En ca
> so afirmativo, indique el motivo de cierre. " (112/211)]: Text not found in
> page. Expected <En caso afirmativo, indique
> el motivo de cierre.>"
>         at
> com.canoo.webtest.ant.WebtestTask.stopBuildIfNeeded(WebtestTask.java:228)
>         at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:175)
>         at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>         at org.apache.tools.ant.Task.perform(Task.java:364)
>         at org.apache.tools.ant.Target.execute(Target.java:341)
>         at org.apache.tools.ant.Target.performTasks(Target.java:369)
>         at
> org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
>         at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.j
> ava:40)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
>         at org.apache.tools.ant.Main.runBuild(Main.java:668)
>         at org.apache.tools.ant.Main.startAnt(Main.java:187)
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
> 
> Total time: 32 seconds
> 
> 
> Thanks for your time. 
> --------------------------------------------------------------------------
> Hi,
> 
> how does your clickLink fail? Does it produce some error or does is it
> just successful but without getting a new page?
> 
> Your js code looks simple and shouldn't be a problem for WebTest
> (neither 2.1 nor 2.5). For 2.1 I could imagine that the default answer
> to confirm was false (I don't remember exactly when the change has been
> done) what could explain that nothing happens. Nevertheless the default
> behavior for confirm is now true so this shouldn't be a problem with
> 2.5. To precisely specify what should happen you can give a try to
> <expectDialogs ...>.
> 
> Last (but not least), to "see" what happens, I recommend you to turn the
> log level to debug (see lib/log4j.properties) and look at what is
> printed to the log when the link is clicked.
> 
> Marc.
> --__--__--
> 
> Message: 3
> From: "Francisco Javier Martin Gutierrez"
> <francisco-javier.martin@thalesgroup.com>
> To: <webtest@lists.canoo.com>
> Date: Thu, 10 May 2007 17:34:48 +0200
> Organization: THALES
> Subject: [Webtest] WebTest clicklink fail
> Reply-To: webtest@lists.canoo.com
> Reply-To: <francisco-javier.martin@thalesgroup.com>
> 
> Hello:
> 
> Since I have been testing with webtest it had never failed like now. I =
> begin
> to believe that webtest do all it can do. But something is going wrong =
> since
> two days ago.
> 
> Webtest (version 2.1 =3D R_1515 and version =3D 2.5 R_1538) can't fail =
> following
> a clickButton image or a clikLink. The page works well on iexplore but
> webtest can't do it. I think it may be that there's some unsupported
> javascript on the page. But how can I be sure of this?
> 
> The page code is:=20
> href=3D"javascript:eliminar('10101A', 'prueba marcos');"
> 
> And the javascript function is:
> function eliminar(codValoracion, nomValoracion) {
>   document.forms[0].codValoracion.value=3DcodValoracion;
>   document.forms[0].nomValoracion.value=3DnomValoracion;
>   document.forms[0].modo.value=3D"listado";
>   document.forms[0].accion.value=3D"eliminar";
>   if(confirm("=BFEst=E1 seguro de que desea eliminar la Valoraci=F3n  '" =
> +
> codValoracion + " : " + nomValoracion + "' de la lista de favoritas?")){
>   	document.forms[0].submit();
>   }
>      =20
> }
> 
> I can't execute a scriptStep because it doesn't provide the mechanism to
> call JavaScript functions in my HTML pages under test as it is told in =
> the
> manual. If you execute a scriptStep at the next form:
> 
> <scriptStep description=3D"boton eliminar" language=3D"javascript">
> 				=09
> 	codValoracion=3D'10101A';
> 	nomValoracion=3D'prueba marcos';
> =09
> document.forms[0].codValoracion.value=3DcodValoracion;
> =09
> document.forms[0].nomValoracion.value=3DnomValoracion;
> 	document.forms[0].modo.value=3D"listado";
> 	document.forms[0].accion.value=3D"eliminar";
> 	if(confirm("=BFEst=E1 seguro de que desea eliminar la Valoraci=F3n
> '" =
> +
> codValoracion + " : " + nomValoracion + "' de la lista de
> favoritas?")){
>   		document.forms[0].submit();
> 	 }
> </scriptStep>
> 
> The error message obtained is:
> 
> [scriptStep]  INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
> scriptStep "boton eliminar" (31/32)
> [scriptStep] ERROR (org.apache.bsf.BSFManager) - Exception :
> [scriptStep] java.security.PrivilegedActionException:
> org.apache.bsf.BSFException: JavaScript Error: Internal Error: org
> .mozilla.javascript.EcmaError: TypeError: Cannot read property "0.0" =
> from
> undefined
> ...
> [scriptStep]  INFO (com.canoo.webtest.steps.Step) - Exception thrown =
> from
> this class: com.canoo.webtest.engine.StepExecu
> tionException
> [scriptStep]  INFO (com.canoo.webtest.steps.Step) - Message was: Error
> invoking script: org.mozilla.javascript.EcmaError
> : TypeError: Cannot read property "0.0" from undefined
>  INFO (com.canoo.webtest.steps.Step) - Running with: Canoo Webtest: =
> R_1515.
> 
> 
> What can I do?
> 
> 
> End of WebTest Digest
> 
> 
> AVISO LEGAL: La informacion contenida en este mensaje y cualquier documento adjunto en el mismo es confidencial, puede estar legalmente protegida y esta dirigida solamente al destinatario. La publicacion, uso, distribucion, impresion o copia no autorizada del contenido de este mensaje, esta estrictamente prohibida y puede ser ilegal. Si Vd. ha recibido este mensaje por error, le rogamos destruya el mensaje y lo notifique al remitente o llame al telefono (+34) 91 556 92 62.
> 
> DISCLAIMER: The information contained in this message and any attached document is confidential, covered by law and intended solely for the recipient. The distribution, print, publication, unauthorised copy and / or use of the message content is strictly forbidden and could be deemed illegal. If you are not the intended recipient of this message, we request that you destroy it and notify the sender either in writing or by calling ++34 91 556 92 62.
> 
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>