我正在尝试在 Internet Explorer 9 上运行一些测试(使用 Protractor)——每个包含“driver.executeScript”的测试都会出现错误:WAITING异步脚本超时(警告:服务器未提供任何堆栈跟踪信息)。其他测试效果很好。
IE 似乎不理解我在函数末尾添加的超时限制(20000 毫秒)- 超时在约 11 秒后到期。
是否有任何 WebdriverJS 代码行让它等待异步执行?
所有测试都在 Firefox 上完美运行。
代码:
#### this one works ####
it("should display selected Date Filter", function() {
ptor.get("data-entry?readingType=no readings after");
var sel = ptor.findElement(protractor.By.selectedOption('data.dateFilterType'));
expect(sel.getText()).toEqual('No readings after date');
}, 20000);
#### this one doesn't work ####
it("should display Selected Locations", function() {
ptor.get("data-entry?locationIds=254,216");
ptor.waitForAngular();
ptor.driver.executeScript("$('#locations').show();");
ptor.sleep(10000);
ptor.findElements(protractor.By.selectedOption('data.locationIds')).then( function(arr) {
expect(arr[0].getText()).toBe('Bovendijk');
expect(arr[1].getText()).toBe('Centrum Locatie');
});
}, 20000);
最佳答案
这里有两个超时 - 单个测试的超时,以及 WebDriver 在浏览器中运行的每个脚本的超时。查看https://github.com/angular/protractor/blob/master/docs/debugging.md#timeouts了解更多信息。
您可以在配置中使用 allScriptsTimeout 设置脚本超时。参见 https://github.com/angular/protractor/commit/e34a4abf9957d2aa73e0d8cda262e624ad15e95e对于引入该选项的 CL。
关于javascript - 在 IE 9 上等待异步脚本超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19380444/