Html 如何单击量角器中的项目列表

Html 如何单击量角器中的项目列表,html,angularjs,protractor,Html,Angularjs,Protractor,HTML代码 <li class="active-result result-selected group-option" data-option-array-index="72">Information Technology and Services</li> 信息技术与服务 在量角器中进行自动化测试时,我无法单击特定的列表项。使用xpath,我可以单击列表项,但不使用xpath,我必须这样做 请帮帮我。你是说点击 <li ng-click="clic

HTML代码

<li class="active-result result-selected group-option" data-option-array-index="72">Information Technology and Services</li>
信息技术与服务 在量角器中进行自动化测试时,我无法单击特定的列表项。使用xpath,我可以单击列表项,但不使用xpath,我必须这样做


请帮帮我。

你是说点击

    <li ng-click="click(72)" class="active-result result-selected group-option" 
data-option-array-index="72">Information Technology and Services</li>

  • 一,
  • 二,
  • 一,
  • 二,
  • 一,
  • 二,

元素(by.id('second-input')).element(by.xpath('following-sibling::ul'))

您可以通过选择按css而不是xpath来单击该项

element.all(by.css('.result-selected')).click();
当元素具有ng click属性时

<li ng-click="selected(72)" class="active-result result-selected group-option" 
    data-option-array-index="72">Information Technology and Services</li>
  • 信息技术和服务

  • 使用此方法将单击列表中的元素



    你们能把你们已经试过的东西贴出来吗?我是角度量角器的新手,所以请帮帮我。我得到了这个错误。未知错误:未知错误:元素在点(426433)处不可单击。其他元素将收到单击:
  • (会话信息:chrome=43.0.2357.132)
    element.all(by.css('.result-selected')).click();
    
    <li ng-click="selected(72)" class="active-result result-selected group-option" 
        data-option-array-index="72">Information Technology and Services</li>
    
      clickElementInList: function (list, item) {
            list.reduce((result, element) => {
                if (result) return result;
                return element.getText().then((text) => {
                    if (text.toLowerCase().includes(item.toLowerCase())) return element;
                });
            }).then((element_found) => {
                if (!element_found) throw new Error(item + " not found");
                this.click(element_found);
            });
        },