[英]Protractor- Timeout while Identifying a nested dropdown element based on a condition
I am trying to identify and select a heavly nested dropdown in my application having following structure(Not exact):我试图在我的应用程序中识别和选择一个重嵌套的下拉列表,它具有以下结构(不准确):
<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>
I have written the following helper function to select the dropdown and I am getting a timeout error.我编写了以下帮助函数来选择下拉菜单,但出现超时错误。
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');
Error Message错误信息
> 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)
Could any one tell me what I am doing wrong?谁能告诉我我做错了什么? Thanks
谢谢
Got it, here is a theory.明白了,这是一个理论。 You are missing the
return
from the each()
call making it executing "forever" and exceeding the default jasmine spec timeout:您错过了
each()
调用的return
,使其“永远”执行并超过了默认的 jasmine 规范超时:
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'));
};
And, I also think you meant to use filter()
instead of each()
..而且,我还认为您打算使用
filter()
而不是each()
..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.