量角器:从弹出值中选择元素

我们有一些文本框,需要从弹出列表中选择值。元素和弹出窗口是这样的:

http://img3.mukewang.com/608a1c96000143af03940103.jpg

相关的html代码如下:


<div _ngcontent-c6="" class="col px-0">

  <input _ngcontent-c6="" aria-multiline="false" autocapitalize="off" 

    autocorrect="off" class="form-control ng-dirty ng-valid open ng-touched"

    formcontrolname="ESYSITENAME" id="esySiteName" name="" placeholder="" 

    role="combobox" type="text" autocomplete="off" aria-autocomplete="list"

    aria-expanded="true" aria-activedescendant="ngb-typeahead-2-0" 

    aria-owns="ngb-typeahead-2">


  <ngb-typeahead-window class="dropdown-menu show ng-star-inserted" 

    role="listbox" id="ngb-typeahead-2" style="top: 39px; left: 0px;">


    <button class="dropdown-item ng-star-inserted active" role="option"

       type="button" id="ngb-typeahead-2-0">


      <ngb-highlight _ngcontent-c6="" _nghost-c25="" class="ng-star-inserted">

          <span _ngcontent-c25="" class="ngb-highlight ng-star-inserted">

              Bull Run Elementary School

          </span>

      </ngb-highlight>

    </button>


  </ngb-typeahead-window>


</div>

我尝试使用不同的策略来选择Popup元素,例如:


let EsyNamePopup = $('#ngb-typeahead-2-0 > ngb-highlight > span');

await helpers.waitForElementVisibility(EsyNamePopup);

await helpers.clickWhenClickable(EsyNamePopup);


// or following way:

let EsyNamePopup = element(by.cssContainingText('span', 'Bull Run Elementary School,));

await EsyNamePopup.click();

他们都不工作,但收到以下错误消息:


NoSuchElementError:使用定位器找不到任何元素:By(css选择器,#ngb-typeahead-2-0> ngb-highlight> span)


是否有更好的策略来选择这些元素?


临摹微笑
浏览 159回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript