我正在尝试识别并选择具有以下结构的应用程序中的重型嵌套下拉列表(不完全):
<tr>..</tr>
<tr>
<td>...</td>
<td>
<grid-field field-name="abc">
<span>
<span>
<span>
<select>
<option value="xyz">Some option</option>
</select>
</span>
</span>
</span>
</grid-field>
</td>
<td>
<grid-field field-name="environment">
<span>
<span>
<span>
<select>
<option value="xyz">Some option</option> /// Required Dropdown
</select>
</span>
</span>
</span>
</grid-field>
</td>
<td>
<grid-field field-name="adasd">
<span>
<span>
<span>
<select>
<option value="xyz">Some option</option>
</select>
</span>
</span>
</span>
</grid-field>
</td>
</tr>
<tr>..</tr>
我编写了以下帮助函数来选择下拉列表,我收到超时错误。
this.selectValueFromDropDown = function(columnName,dropDownData){
this.getDropDown(columnName).$("[value='".concat(dropDownData).concat("']")).click();
};
this.getDropDown = function(columnName){
return element.all(by.tagName('tr')).filter(function(row){
return row.all(by.tagName('grid-field')).each(function(gridField){
gridField.getAttribute('field-name').then(function(attribute){
return attribute === columnName;
});
});
}).first().element(by.tagName('select'));
};
// Spec
gridObject.selectValueFromDropDown('environment','xyz');
错误消息
> Message:
> Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Stack:
> Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
> at [object Object]._onTimeout (C:\Users\taaupsa1\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1812:23)
有谁能告诉我我做错了什么?感谢
答案 0 :(得分:1)
知道了,这是一个理论。您错过了return
来自each()
的{{1}}来使其执行&#34;永远&#34;并超过默认的茉莉花规格超时:
this.getDropDown = function(columnName){
return element.all(by.tagName('tr')).filter(function(row){
return row.all(by.tagName('plm-grid-field')).each(function(gridField){
// v HERE
return gridField.getAttribute('field-name').then(function(attribute){
return attribute === columnName;
});
});
}).first().element(by.tagName('select'));
};
而且,我还认为您打算使用filter()
代替each()
..