2017-05-19 17 views
0

ドロップダウンリストで3番目のオプションを選択しようとしています。トラブルシューティング角度ナビUIナビの角度要素

外HTML::

<md-option _ngcontent-c6="" role="option" ng-reflect-value="last90Days" tabindex="0" id="md-option-2" aria-selected="false" aria-disabled="false" class="mat-option"><!--bindings={ 
    "ng-reflect-ng-if": "false" 
}--> Last 90 Days <!--bindings={ 
    "ng-reflect-ng-if": "true" 
}--><div class="mat-option-ripple mat-ripple" md-ripple="" ng-reflect-trigger="[object HTMLElement]"> </div> </md-option> 

CSSセレクタ:ひどいフォーマットのため

#md-option-37 > div:nth-child(1) 

申し訳ありませんが、以下の要素についてのいくつかの詳細があります。誰かが "最後の90日間"のドロップダウンアイテムを選択する方法について何か提案があれば、とても感謝しています。

答えて

2

私は、私は常にセレクタの残りのため、shorthand notationを使用あなたはelement(by.css('selector'));については、以下の

// Open the md-select, use the correct selector, this is a demo 
 
$('md-select').click(); 
 

 
// There is an animation, I don't know how long, you need to wait for the animation to be finished. 
 
// Quick and dirty is a browser.sleep(), but it's better to find a more stable way because if the animation will take longer in the future your test will break 
 
browser.sleep(500); 
 

 
// Click on you option, this can be done in several ways 
 

 
// By index 
 
$$('md-option').get(1).click(); 
 
// By text 
 
element(by.cssContainingText('md-option', 'your text')).click(); 
 

 
// Wait for the menu to close, this is also an animation 
 
browser.sleep(500);

を行う必要がありmd-select AngularJSあなたの情報のうち、理解した内容に基づいて、 docs of Protractorを参照してください。

私はアニメーションが完了するのを待つためのより良い方法を使用することをお勧めします。ここではbrowser.sleep()を使用しましたが、これは将来の証明ではありません。あなたはあなたのスクリプトが眠りに頼ることを望んでいません。

希望します。

+0

ありがとうございます! – rHenderson

関連する問題