[Webtest] Re: javascript link (Denis N. Antonioli) RE: WebTest digest, Vol 1 #1860 - 5 msgs

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Thu, 07 Jun 2007 13:35:13 +0200


Francisco,

have you looked at the url that you invoke:
http://espinete:7783/sauss/<a href="javascript:eliminar('10101A',
'prueba marcos');"><img src="imagenes/ico_eliminar.gif" alt="eliminar"
width="8" height="9" border="0"></a>

yes, this whole string with all <, >, and other chars! Even if it's
technically possible, I really, really doubt, that it is what you want
to do!

I think, I've already said it, but the usage of reg ex here doesn't make
sense at all.

You have to identify the link and click it. The more powerful way for
that is the xpath attribute of clickLink. If you can identify the link
but if the click doesn't produce the right effect, then this means that
there are some problem in the js function evaluation and the only way to
fix it is to understand what is wrong in the js function evaluation. If
the js fails when the link is clicked, it has no chance to function
better when the javascript:... url is invoked directly.

Marc.

Francisco Javier Martin Gutierrez wrote:
> Hello:
> 
> Thank all for your disinterested help. After last mail I think that I got
> the correct regular expression.
> 
> LINK
> <a href="javascript:eliminar('10101A', 'prueba marcos');"><img
> src="imagenes/ico_eliminar.gif" alt="eliminar" width="8" height="9"
> border="0"></a> 
> 
> REGULAR EXPRESSION
> text="&lt;a\shref=&quot;javascript:eliminar\(&apos;10101A&apos;,\s&apos;prue
> ba\smarcos&apos;\);&quot;&gt;&lt;img\ssrc=&quot;imagenes/ico_eliminar.gif&qu
> ot;\salt=&quot;eliminar&quot;\swidth=&quot;8&quot;\sheight=&quot;9&quot;\sbo
> rder=&quot;0&quot;&gt;&lt;/a&gt;"    
> 
> I have learnt a lot about regular expressions but the expected result did
> not arrive. Test failed again. 
> 
> TEST REPORT
> [storeRegEx]  INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
> storeRegEx "Extract target location from javascript command" (58/61)
> [invoke]  INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: invoke
> "Invoke target page specified in the javascript statement" (58/61)
> [invoke]  INFO (com.canoo.webtest.steps.request.AbstractTargetAction) - ->
> gotoTarget by URL: <a href="javascript:eliminar('10101A', 'prueba
> marcos');"><img src="imagenes/ico_eliminar.gif" alt="eliminar" width="8"
> height="9" border="0"></a>
> [invoke]  INFO (com.canoo.webtest.steps.request.TargetHelper) - getting
> response for url: http://espinete:7783/sauss/<a
> href="javascript:eliminar('10101A', 'prueba marcos');"><img
> src="imagenes/ico_eliminar.gif" alt="eliminar" width="8"
> height="9" border="0"></a>
> [invoke]  INFO (com.gargoylesoftware.htmlunit.WebClient) - statusCode=[404]
> contentType=[text/html]
> [invoke]  INFO (com.gargoylesoftware.htmlunit.WebClient)
> -<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>4
> 04 Not
> Found</H1>Resource/sauss/%3Ca%20href=%22javascript:eliminar('10101A',%20'pru
> eba%20marcos');%22%3E%3Cimg%20src=%22imagenes/ico_eliminar.gif%22%20alt=%22e
> liminar%22%20width=%228%22%20height=%229%22%20border=%220%22%3E%3C/a%3E not
> found on this server</BODY></HTML>
> 
> However, I appreciate your suggestions and if you have any other idea to
> click on the link, I will be happy to try it again.
> 
> 
> Francisco Javier Martín 
> Desarrollo de Proyectos - Valladolid
> Security Solutions & Services Division 	
> 	 
> Edif. Solar, Of. 13, 14, 15
> Parque Tecnológico Boecillo. 47151 Valladolid. España
> Tel.: 983 54 65 55   Fax: 983 54 66 09	 

-- 
Blog: http://mguillem.wordpress.com