[Webtest] Looking for wicket:id with XPath

Marcin Zajączkowski Marcin Zajączkowski
Tue, 26 Nov 2013 14:55:21 +0100


Thanks Marcel for a quick response.

On 2013-11-26 14:10, Marcel Primeau wrote:
> Hi Marcin,
>  
> Did you try this :
>  
>   <clickButton label="Cancel" 
>            xpath="//*[@class='btn']"/>
>  
> this is another way to check a button.

Unfortunately it doesn't work. In WebTestReport.xml I have:
> <detail name="available buttons"><![CDATA[In current form:
> HtmlButton[<button name="userEditPanel:buttonsGroup:saveButton" id="saveButton5" value="Save" class=" btn-primary btn">], HtmlButton[<button onclick="var win = this.ownerDocument.defaultView || this.ownerDocume
> t.parentWindow; if (win == window) { window.location.href='./userEdit?3-1.ILinkListener-userEditForm-userEditPanel-buttonsGroup-cancelButton'; } ;return false" class=" btn">]]]]></detail>

Maybe the reason is that this button doesn't have a "normal" label, but
rather:
> <button class="btn " onclick="var win = this.ownerDocument.defaultView || this.ownerDocument.parentWindow; if (win == window) { window.location.href='./userEdit?7-1.ILinkListener-userEditForm-userEditPanel-buttonsGroup-cancelButton'; } ;return false" wicket:id="cancelButton">
> <wicket:panel>
> <i class="icon-remove" wicket:id="icon"></i>
> <span wicket:id="splitter"> </span>
> Cancel
> </wicket:panel>
> </button>


Marcin


> De : Marcin Zajączkowski <mszpak@wp.pl>
> À : webtest@lists.canoo.com 
> Envoyé le : mardi 26 novembre 2013 7h48
> Objet : [Webtest] Looking for wicket:id with XPath
> 
> 
> Hi,
> 
> I try to use WebTests to locate a quite unpleasant button (link)
> generate by a Wicket-Bootstrap library.
> 
>> <button class="btn " onclick="var win = this.ownerDocument.defaultView || this.ownerDocument.parentWindow; if (win == window) { window.location.href='./userEdit?7-1.ILinkListener-userEditForm-userEditPanel-buttonsGroup-cancelButton'; } ;return false" wicket:id="cancelButton">
> 
> WebTest recorder suggests:
>> <clickButton label="Cancel "/>
> 
> but it doesn't work. I tried with looking for wicket:id with xpath:
>> //button[@*[local-name()='wicket:id']='cancelButton']
> 
> and it works fine in a WebTest recorder, but unfortunately doesn't match
> anything when used in xml:
> 
>> <clickbutton xpath="//button[@*[local-name()='wicket:id']='cancelButton']" description="Click Cancel"/>
> 
> I can use index to locate this button, but xpath by wicket:id would be
> more precise. Is this xpath syntax supported?
> 
> webtest-maven-plugin 1.0.0 with htmlunit upgraded to 2.12.
> 
> Marcin
> 


-- 
http://blog.solidsoft.info/ - Working code is not enough