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:"lote-form-button-gerar-xml-tiss",u:"lote-form-panel-grid-dados-lote lote-form-buttons",onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:"form"});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:"lote-form-button-gerar-impressao-tiss",u:"form",onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:"form"});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:"lote-form-button-gerar-documentos-lote",u:"form",onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:"form"});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:"lote-form-button-gerar-xml-tiss",u:"lote-form-panel-grid-dados-lote lote-form-buttons",onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:"form"});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:"lote-form-button-gerar-xml-tiss",u:"lote-form-panel-grid-dados-lote lote-form-buttons",onst:function(cfg){PF('statusDialog').show();;},onco:function(xhr,status,args){PF('statusDialog').hide();;},f:"form"});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.
You should use the ID to select it. The ID is guaranteed to be unique.
.click("#lote-form-button-gerar-xml-tiss")
Assuming the page has loaded and this element is not in an iframe, there is no reason the above click shouldn't work.