【问题标题】:Protractor: Browser.wait() Timeout is timing out on Jasmine defaultTimeoutInterval量角器:Browser.wait() Timeout 在 Jasmine defaultTimeoutInterval 上超时
【发布时间】:2020-09-25 03:48:41
【问题描述】:

我目前正在尝试使用 browser.wait() 确保否定测试。下面的测试打开页面,执行搜索,清除搜索结果并等待搜索结果可见。下面的测试应该在 5 秒后超时,因为元素在被清除后将永远不可见,但是使用 conf.js 文件中设置的 defaultTimeoutInterval(30 秒)会超时。我是否需要更改我的 conf.js 设置以使用 browser.wait() 语句中指定的超时间隔?

我正在运行 Protractor 版本 5.3.2

conf.js 文件中设置的默认超时间隔

// Options to be passed to Jasmine.
jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report. 
    defaultTimeoutInterval: 30000 // Default time to wait in ms before a test 
fails.
},

我在 spec.js 文件中的测试

//require page object, actions
var advisorUI = require('../pages/advisor_ui_po.js');
var advisorUIActions = require('../actions/advisor_ui_pa.js');
var advisorUISearchResults = require('../pages/search_results1_po.js');
var advisorUISearchResults2 = require('../pages/search_results2_po.js');
var testExecActions = require('../actions/test_exec_a.js');

//Create instance of the Advisor UI page object
beforeEach(async function () {
 await advisorUI.get();
});

describe('Search By Email', function() {
    it('should display search results', async function() {
        //Execute the Search by email
        var email = browser.params.smoketestdata.email;
        advisorUIActions.searchByEmail(email);
        advisorUIActions.clearSearch();
        var EC = protractor.ExpectedConditions;browser.wait(EC.visibilityOf(advisorUISearchResults.getShowingResultsForLabel(), 5000, 'Wait Timeout is working!')); 
    });
});

这是输出:

λ protractor conf.js --suite regression
Report destination:   screenshots\my-report.html
(node:19008) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use 
os.tmpdir() instead.
[12:04:55] I/launcher - Running 1 instances of WebDriver
[12:04:55] I/hosted - Using the selenium server at 
http://localhost:4444/wd/hub
Started
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.

Failures:
1) Search By Email should display search results
  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 ontimeout (timers.js:498:11)
        at tryOnTimeout (timers.js:323:5)
        at Timer.listOnTimeout (timers.js:290:5)
  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 ontimeout (timers.js:498:11)
        at tryOnTimeout (timers.js:323:5)
        at Timer.listOnTimeout (timers.js:290:5)

1 spec, 1 failure
Finished in 61.941 seconds

[12:06:01] I/launcher - 0 instance(s) of WebDriver still running
[12:06:01] I/launcher - chrome #01 failed 1 test(s)
[12:06:01] I/launcher - overall: 1 failed spec(s)
Closing report
[12:06:01] E/launcher - Process exited with error code 1

【问题讨论】:

    标签: javascript jasmine protractor


    【解决方案1】:

    尝试在每个测试中返回回调。请做一些断言并返回回调,以便您的测试继续进行。因为您从未返回回调,Jasmine 认为您在等待什么。

    确保在完成测试中的所有步骤(即在 it() 块内)后返回回调。

    【讨论】:

    • 谢谢!我意识到它也无法在 DOM 中找到该元素。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-29
    相关资源
    最近更新 更多