我是一個新出生的QA,我在這裏試圖編寫一個量角器腳本來從下拉列表中選擇一個選項。在我的下拉菜單中有2個選項,我試圖從數字中選擇它。在量角器中選擇一個特定的選項
這是我正在使用的代碼。
var selectDropdownbyNum = function (element, optionNum) {
if (optionNum){
var options = element.findElements(by.tagName('entity.company_id as entity.company_name for entity in entities'))
.then(function(options){
options[1].click();
});
}
};
當頁面加載時默認選擇選項2。我需要的是從下拉菜單中選擇選項1。但是,我的代碼沒有這樣做。
以下是select選項的代碼片段。
<select required="required" class="form-control empty ng-pristine ng-valid ng-not-empty ng-valid-required ng-touched" name="entity_id" ng-model="invoice.entity_id" ng-options="entity.company_id as entity.company_name for entity in entities" ng-required="true" ng-change="entitySelect(invoice.entity_id)">
<option value="string:568f97841a4885e5de39900e" label="Option Global">Option Global</option>
<option selected="selected" value="string:568f976a1a4885e5de39900d" label="Option Computer Studies">OptionComputer Studies</option>
</select>
感謝提前:)
看看http://stackoverflow.com/questions/28723419/select-option-abstraction。很方便。 – alecxe