代码之家  ›  专栏  ›  技术社区  ›  Sundaze

量角器点击包裹的p下拉列表-选择值-元素在点(x,y)不可点击其他元素将收到点击

  •  0
  • Sundaze  · 技术社区  · 6 年前

    我正在尝试选择我的P日历元素。 这是一个下拉列表,我想点击打开它。 打开后,我想从列表中选择(clilck)一个值。

    但我甚至不能单击下拉元素。

    选择下拉元素:

    input = element(by.css('p-dropdown[formcontrolname="currId"]'));
    

    这是可行的。 但是现在当你试图点击它的时候:
    我收到以下错误:

    </p-dropdown> is not clickable at point (841, 415). Other element would receive the click: <a cla
    

    我知道我必须选择标签:

    input.$('label').click();
    

    但这也不管用。

    </label> is not clickable at point (841, 416). Other element would receive the click: <a class="ui-s
    

    我的p下拉元素:

    <p-dropdown formcontrolname="currId" id="currId" inputid="currId" placeholder="NONE" 
      styleclass="form-control form-control-sm" 
      class="ng-tns-c6-1 ng-untouched ng-pristine ng-invalid" ng-reflect-filter="true" 
      ng-reflect-style-class="form-control form-control-sm" ng-reflect-placeholder="NONE" 
      ng-reflect-input-id="currId" ng-reflect-options="[object Object],[object Object" 
      ng-reflect-name="currId">
      <div class="ng-tns-c6-1 form-control form-control-sm ui-dropdown ui-widget ui-state-default ui-corner-all ui-helper-clearfix" 
           ng-reflect-klass="form-control form-control-sm" 
           ng-reflect-ng-class="[object Object]" style="width: 96px;">
        <select>
          <option class="ng-tns-c6-1 ng-star-inserted" value="AED">AED</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="AUD">AUD</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="BGN">BGN</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="BRL">BRL</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="CAD">CAD</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="CHF">CHF</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="CLP">CLP</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="CNY">CNY</option>
          <option class="ng-tns-c6-1 ng-star-inserted" value="COP">COP</option>
        </select>
      </div>
      <div class="ui-helper-hidden-accessible">
        <input class="ng-tns-c6-1" readonly="" role="listbox" type="text" id="currId" aria-label=" ">
      </div>
      <label class="ng-tns-c6-1 ui-dropdown-label ui-inputtext ui-corner-all ui-placeholder ng-star-inserted" ng-reflect-ng-class="[object Object]">NONE</label>
      <div class="ui-dropdown-trigger ui-state-default ui-corner-right">
        <span class="ui-clickable fa fa-fw fa-caret-down" ng-reflect-klass="ui-clickable" ng-reflect-ng-class="fa fa-fw fa-caret-down"></span>
      </div>
      <div class="ng-tns-c6-1 ui-dropdown-panel ui-widget-content ui-corner-all ui-shadow ng-trigger ng-trigger-panelState" ng-reflect-ng-class="ui-dropdown-panel ui-widget-co" style="display: none; opacity: 0;">
        <div class="ui-dropdown-filter-container ng-tns-c6-1 ng-star-inserted" style="">
          <input class="ui-dropdown-filter ui-inputtext ui-widget ui-state-default ui-corner-all" autocomplete="off" type="text">
          <span class="fa fa-search"></span>
        </div>
        <div class="ui-dropdown-items-wrapper" style="max-height: 200px;">
        </div>
      </div>
      </div>
    </p-dropdown>
    

    如何选择并单击此项?

    2 回复  |  直到 6 年前
        1
  •  1
  •   RagnarOdin    6 年前

    看起来像 a 元素干扰了单击-这可能有多种原因。最后,您可以尝试执行一些javascript以将其可见性设置为隐藏:

    elem = element(by.css('a.ui-s') <-在此处输入类名的其余部分

    browser.executeScript("arguments[0].style.visibility='hidden'", elem)
    
        2
  •  0
  •   Sundaze    6 年前

    所以问题实际上是其他的下拉窗口,以前打开过,但没有关闭。这覆盖了整个页面和我想要点击的元素。 我以前刚关上所有其他打开的窗户