【问题标题】:Timeout expired waiting for async script on IE 9在 IE 9 上等待异步脚本超时已过期
【发布时间】:2013-10-23 05:04:32
【问题描述】:

我正在尝试在 Internet Explorer 9 上运行一些测试(使用 Protractor) - 每个包含“driver.executeScript”的测试都会给出错误:等待异步脚本超时(警告:服务器未提供任何堆栈跟踪信息)。其他测试工作得很好。

似乎 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);

【问题讨论】:

  • 你能告诉我们一些你给超时限制的代码吗?
  • it("应该显示选定的位置", function() { ptor.get("data-entry?locationIds=254,216"); ptor.waitForAngular(); ptor.driver.executeScript("$ ('#locations').show();"); ptor.findElements(protractor.By.selectedOption('data.locationIds')).then( function(arr) { expect(arr[0].getText()) .toBe('Bovendijk'); expect(arr[1].getText()).toBe('Centrum Locatie'); }); }, 20000);

标签: javascript angularjs selenium-webdriver webdriver protractor


【解决方案1】:

这里有两个超时 - 单个测试的超时,以及 WebDriver 在浏览器中运行的每个脚本的超时。查看https://github.com/angular/protractor/blob/master/docs/debugging.md#timeouts 了解更多信息。

您可以使用 allScriptsTimeout 在配置中设置脚本超时。有关引入该选项的 CL,请参阅 https://github.com/angular/protractor/commit/e34a4abf9957d2aa73e0d8cda262e624ad15e95e

【讨论】:

  • 我按照你说的修改了文件,现在我得到了:“超时:在 20000 毫秒后超时等待规范完成”仅在 IE9 上。我认为 ptor.driver.executeScript 在 IE 上不起作用
猜你喜欢
  • 2016-02-15
  • 2016-09-04
  • 1970-01-01
  • 2016-09-05
  • 2021-05-25
  • 2016-09-01
  • 2021-10-12
相关资源
最近更新 更多