2017-10-03 18 views
0

Angularでビルドされている私のアプリケーションの1ページで、通常のselenium webdriverを使用するのに深刻な問題があります。私はpg.xmlにngwebdriverの依存関係を追加しましたが、これまでいくつかの問題を解決しました。ドロップダウンだけで、私はまだこれを行う方法を考え出していない。これは私が話していますドロップダウンです:分度器でドロップダウンから要素を選択

<d3-data-list _nghost-c8="" ng-reflect-data-source="[object Object]" ng- 
reflect-html-id="documents_glossary_entityPicke" ng-reflect-allow-blank- 
option="true" ng-reflect-blank-option-text="All entities" ng-reflect-default- 
caption="Choose an entity"><div _ngcontent-c8="" class="dropdown d3-data- 
list" id="documents_glossary_entityPicker"> 
    <button _ngcontent-c8="" aria-expanded="true" aria-haspopup="true" class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button" id="documents_glossary_entityPicker_button"> 
All entities 
<span _ngcontent-c8="" class="caret" 
id="documents_glossary_entityPicker_caret"></span> 
    </button> 
    <ul _ngcontent-c8="" aria-labelledby="dropdownMenu1" class="dropdown-menu" 
ng-reflect-infinite-scroll-handle-in-progress="false" 
id="documents_glossary_entityPicker_dropdown"> 
    <!--bindings={ 
     "ng-reflect-ng-if": "true" 
}--><li _ngcontent-c8=""> 
     <a _ngcontent-c8="" 
id="documents_glossary_entityPicker_blank_option">All entities</a> 
</li> 

は、ドロップダウンからオプションは、このようなものです:

</li><li _ngcontent-c8=""> 
    <a _ngcontent-c8="" id="documents_glossary_entityPicker_option_2">Entity three</a> 
</li> 

問題は、私のドロップの要素の順序要素(エンティティ)が別のページで編集された場合、リストの一番下に表示されるため、削除は維持されません。だから私は本当に私の要素がドロップダウンリストのどこにあるか本当に知ることができません。

私の場合に使用できるbrowser.findElement(ByAngular.buttonText("text"))のようなものがありますか?ありがとう。

答えて

0

filter()または.reduce()の可能性を探しているようです。 .filter()あなたのコードの場合.reduce()チェックthe example here

については

は、次のようになります。

element.all(by.css('ul li a')).filter(function (elm) { 
    return elm.getAttribute('value').then(function (text) { 
     return text === "TheValueYouLookFor"; 
    }); 
}).first().click(); 

私は自分自身をこの.filterをテストしていないが、それはかなりまっすぐ進むProtractor documentationからです。

関連する問題