Selecting tabindex in Nightwatch
Asked 07 September, 2021
Viewed 1.9K times
  • 59
Votes

Im trying to select an specific button in my page, but nightwatch can't seem to find it. If I try to call it by class, it works but doesn't select the button that I want it to

<div id="btGerar_documentosLote_menu" class="ui-menu ui-menu-dynamic ui-widget ui-widget-content ui-corner-all ui-helper-clearfix ui-shadow" role="menu">
<ul class="ui-menu-list ui-helper-reset"><li class="ui-menuitem ui-widget ui-corner-all" role="menuitem">
enter code here
<a tabindex="-1" id="lote-form-button-gerar-xml-tiss" class="ui-menuitem-link ui-corner-all" href="#" onclick="PrimeFaces.ab({s:&quot;lote-form-button-gerar-xml-tiss&quot;,u:&quot;lote-form-panel-grid-dados-lote lote-form-buttons&quot;,onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:&quot;form&quot;});return false;">
<span class="ui-menuitem-text">Gerar XML TISS</span
></a></li>
<li class="ui-menuitem ui-widget ui-corner-all" role="menuitem"><a tabindex="-1" id="lote-form-button-gerar-impressao-tiss" class="ui-menuitem-link ui-corner-all" href="#" onclick="PrimeFaces.ab({s:&quot;lote-form-button-gerar-impressao-tiss&quot;,u:&quot;form&quot;,onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:&quot;form&quot;});return false;"><span class="ui-menuitem-text">Gerar Impressão TISS</span></a>
</li>
<li class="ui-menuitem ui-widget ui-corner-all" role="menuitem">
<a tabindex="-1" id="lote-form-button-gerar-documentos-lote" class="ui-menuitem-link ui-corner-all" href="#" onclick="PrimeFaces.ab({s:&quot;lote-form-button-gerar-documentos-lote&quot;,u:&quot;form&quot;,onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:&quot;form&quot;});return false;">
<span class="ui-menuitem-text">Gerar Documentos Lote</span></a></li></ul></div>

If I try to select <li class="ui-menuitem ui-widget ui-corner-all" role="menuitem"><a tabindex="-1" id="lote-form-button-gerar-xml-tiss" class="ui-menuitem-link ui-corner-all" href="#" onclick="PrimeFaces.ab({s:&quot;lote-form-button-gerar-xml-tiss&quot;,u:&quot;lote-form-panel-grid-dados-lote lote-form-buttons&quot;,onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:&quot;form&quot;});return false;"><span class="ui-menuitem-text">Gerar XML TISS</span></a></li>, it doesn't work but nightwatch recognizes it as a valid command.

If I try to select the button directly, which is <a tabindex="-1" id="lote-form-button-gerar-xml-tiss" class="ui-menuitem-link ui-corner-all" href="#" onclick="PrimeFaces.ab({s:&quot;lote-form-button-gerar-xml-tiss&quot;,u:&quot;lote-form-panel-grid-dados-lote lote-form-buttons&quot;,onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:&quot;form&quot;});return false;"><span class="ui-menuitem-text">Gerar XML TISS</span></a>, it doesn't recognize my command. Returns it to me as if it is wrong.

Trying to select the element by using .click('li[class="ui-menuitem ui-widget ui-corner-all"]')

If someone could help me solve this, i'd be grateful. If you want any more info on the code, just ask me for it.

1 Answer