1

There are three Save buttons in the webpage which has dynamic ID. Guide me how to define the best xpath, currently I have applied the full xpath starting html node.

First Save Button HTML code

<button id="j_idt131" name="j_idt131" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button" onclick="PrimeFaces.ab({source:'j_idt131',update:'csqa_form',oncomplete:function(xhr,status,args){if (args &amp;&amp; !args.validationFailed) qaChangeDialog.show();}});return false;" type="submit" role="button" aria-disabled="false"><span class="ui-button-text ui-c">Save</span></button>

Second Save Button HTML code

<button id="j_idt104" name="j_idt104" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button" onclick="PrimeFaces.ab({source:'j_idt104',update:'cemail_form',oncomplete:function(xhr,status,args){if (args &amp;&amp; !args.validationFailed) emailChangeDialog.show();}});return false;" type="submit" role="button" aria-disabled="false"><span class="ui-button-text ui-c">Save</span></button>

Third Save Button HTML code

<button id="j_idt82" name="j_idt82" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button" onclick="PrimeFaces.ab({source:'j_idt82',update:'cpwd_form',oncomplete:function(xhr,status,args){if (args &amp;&amp; !args.validationFailed) pwdChangeDialog.show();}});return false;" type="submit" role="button" aria-disabled="false"><span class="ui-button-text ui-c">Save</span></button>

enter image description here

nitin chawda
  • 1,378
  • 11
  • 24
Thirumalai
  • 59
  • 1
  • 8

2 Answers2

1

Since you know the order of the buttons, you could try this xpath,

//button[contains(@id,"j_idt")][1]
//button[contains(@id,"j_idt")][2] 
//button[contains(@id,"j_idt")][3] 
Vignesh Paramasivam
  • 2,360
  • 5
  • 26
  • 57
0

HI can you please provide the full page markup maybe through a pastie link I reckon you can use AxisName by selection //label[.='Answert3']/following::button[.='Save']

Zach
  • 986
  • 7
  • 19