量角器:Browser.wait() 超时在 Jasmine 默认超时间隔上超时



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

我正在运行量角器版本 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.
},

我在规范.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:   screenshotsmy-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

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

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

最新更新