0

Ich habe Schwierigkeiten mit dem Versuch, ein Produkt namens "irgendein Produkt" aus dem folgenden Dropdown-Menü auszuwählen. 'id = "s2id_autogen81"' ist das neue ID-Element, ich habe diese ID verwendet, um das Objekt zu erfassen, aber es wurde auf diesen Auto-Gen-Wert geändert und ich bin mir nicht sicher, was ich mit Winkelmesser greifen soll.Wie kann ich aus einer Dropdown-Liste im Winkelmesser auswählen?

aus dem Drop-down-Menü, bevor es

<div class="select2-container ng-pristine ng-untouched ng-valid" id="s2id_autogen81"> 
    <a href="javascript:void(0)" class="select2-choice select2-default" tabindex="-1"> 
     <span class="select2-chosen" id="select2-chosen-82">Select a product</span> 
     <abbr class="select2-search-choice-close"></abbr> 
     <span class="select2-arrow" role="presentation"> 
      <b role="presentation"></b> 
     </span> 
    </a> 
    <label for="s2id_autogen82" class="select2-offscreen"></label> 
    <input class="select2-focusser select2-offscreen" type="text" aria-haspopup="true" role="button" aria-labelledby="select2-chosen-82" id="s2id_autogen82"> 
</div> 

aus dem Drop-down nach der Auswahl es

<div class="select2-drop select2-display-none select2-with-searchbox select2-drop-active" id="select2-drop" style="left: 86.4375px; width: 258px; top: 831px; bottom: auto; display: block;"> 
<div class="select2-search">  
<label for="s2id_autogen11_search" class="select2-offscreen">Product</label>  
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="select2-input" role="combobox" aria-expanded="true" aria-autocomplete="list" aria-owns="select2-results-11" id="s2id_autogen11_search" placeholder="" aria-activedescendant="select2-result-label-15"> 
</div> 
<ul class="select2-results" role="listbox" id="select2-results-11"><li class="select2-results-dept-0 select2-result select2-result-selectable ng-binding ng-hide" role="presentation"> 
    <div class="select2-result-label" id="select2-result-label-13" role="option"> 
    <span class="select2-match"> 
     </span> 
    </div> 
    </li> 
<li class="select2-results-dept-0 select2-result select2-result-selectable ng-binding ng-scope" role="presentation"> 
    <div class="select2-result-label" id="select2-result-label-14" role="option"> 
    <span class="select2-match"> 
     </span>NOT SOME PRODUCT 
    </div> 
    </li> 
<li class="select2-results-dept-0 select2-result select2-result-selectable ng-binding ng-scope select2-highlighted" role="presentation"> 
    <div class="select2-result-label" id="select2-result-label-15" role="option"> 
    <span class="select2-match"> 
     </span>SOME PRODUCT 
    </div> 
    </li> 
</ul> 

+1

Wo ist das 'irgendein Produkt' im HTML? – alecxe

+0

@alecxe Ich habe den Beitrag aktualisiert danke. – arenfroe

Antwort

1

Versuchen Sie verwenden folgenden Code auswählen.

element.all(by.model('ng-model of the drop down list')).each(function (eachElement, index) 
    { 
     eachElement.click();// select the <select> 
     browser.driver.sleep(500);// wait for the renderings to take effect 
     element(by.css('unique selector of the item you need to select')).click();// select the first md-option 
     browser.driver.sleep(500);// wait for the renderings to take effect 
    }); 
Verwandte Themen