在 Nightwatch 中选择 tabindex

Selecting tabindex in Nightwatch

我正在尝试 select 我页面中的特定按钮,但 nightwatch 似乎找不到它。如果我尝试通过 class 调用它,它可以工作,但不会 select 我想要的按钮

<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>

如果我尝试 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>,它不起作用,但 nightwatch 将其识别为有效命令。

如果我尝试直接 select 按钮,即 <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>,它无法识别我的命令。 Returns 这对我来说好像是错误的。

尝试使用 .click('li[class="ui-menuitem ui-widget ui-corner-all"]')

select 元素

如果有人能帮我解决这个问题,我将不胜感激。如果您想了解有关代码的更多信息,请向我索取。

您应该使用 ID select 它。 ID 保证是唯一的。

.click("#lote-form-button-gerar-xml-tiss")

假设页面已加载且此元素不在 iframe 中,则上述点击没有理由不起作用。