gpt4 book ai didi

javascript - Protractor:Browser.wait() Timeout 在 Jasmine defaultTimeoutInterval 上超时

转载 作者:行者123 更新时间:2023-12-03 01:20:52 24 4
gpt4 key购买 nike

我目前正在尝试使用 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

最佳答案

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

一旦完成测试中的所有步骤(即 it() block 内的步骤),请确保返回回调。

关于javascript - Protractor:Browser.wait() Timeout 在 Jasmine defaultTimeoutInterval 上超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51773004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com