如何解决量角器测试无限期挂起的问题?
How can I resolve an issue where a Protractor test hangs indefinitely?
我遇到了一个问题,我以前运行过一个测试用例,我知道它正在工作,现在在执行时无限期地卡住了。每次测试单击一个特定的元素时都会发生这种情况。测试只是挂起,无法继续执行脚本。除了超时错误外,不发生任何错误。当我运行测试时,我得到常规提示:
[11:58:20] I/direct - Using ChromeDriver directly...
[11:58:20] I/launcher - Running 1 instances of WebDriver
Started
A Jasmine spec timed out. Resetting the Webdriver Control Flow.
F
Failures:
1) clicks menu buttons
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 Timer.listOnTimeout (timers.js:92:15)
1 spec, 1 failure
Finished in 3000.147 seconds
[12:48:47] I/launcher - 0 instance(s) of Webdriver still running
[12:48:47] I/launcher - chrome #01 failed 1 test(s)
[12:48:47] I/launcher - overall: 1 failed spec(s)
[12:48:47] E/launcher - Process exited with error code 1
然后它就挂在那里,直到达到我设置的超时。以下是我正在使用的配置和部分测试脚本的副本。
config.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect: true,
//getPageTimeout: timeout_in_millis
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
//'browserName': 'firefox'
},
//suites:{},
specs: ['basic_testing.js'],
allScriptsTimeout: 3000000,
//framework: 'jasmine2',
onPrepare: function() {
browser.driver.manage().window().maximize();
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'testresults',
filePrefix: new Date().toJSON().substring(0,10).replace(/-/g , "") + '_xmloutput'
}))
},
//Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 3000000
}
};
basic_testing.js
describe('menu page', function()
{
it('clicks menu buttons', function()
{
element(by.id("nav-group-ServiceOrders")).click();
element(by.id("nav-item-Dashboard")).click();
//This element is clicked but then the test hangs here
element(by.id("nav-item-OrdersConsole")).click();
element(by.id("nav-item-PersonnelConsole")).click();
element(by.id("nav-item-PriorityPoints")).click();
});
});
如果您已经探索了超时,并且仍然面临问题,那么如果点击第一个元素后的结果页面加载了第二个要点击的元素,但需要花时间加载页面中的所有元素,然后停止进一步加载元素并继续点击第二个元素,则使用browser.executeScript('window.stop();');
。您的代码将如下所示。
var EC = protractor.ExpectedConditions;
1stElement.click();
browser.wait(EC.presenceOf(2ndElement), 5000);
browser.wait(EC.visibilityOf(2ndElement), 5000);
browser.executeScript('window.stop();');
2ndElement.click();
相关文章:
- JavaScript执行暂时挂起页面
- 是定义的操作系统睡眠/挂起期间setTimeout的行为
- Chrome浏览器“;挂起”;同时在循环中执行AJAX请求
- fullcalendar在删除导致浏览器挂起的多个事件时速度较慢
- 应用将图表转换为图像的jqplot代码时Chrome挂起
- 如何在不使用Internet Explorer的情况下从未挂起的HTML文件执行程序
- MongoDB collection.find()查询挂起
- 使用子字符串方法时应用程序挂起的原因
- 如何在AngularJS中取消挂起的请求
- 从node.js应用程序调用Mongoose Model.save()时挂起
- Chrome,Safari在从本地存储读取时挂起,而Firefox很好
- IE 10 挂起 XMLHttpRequest 6 分钟,然后响应请求(使用 AngularJS 实现 CRSF)
- 挂起 JavaScript 键关闭事件
- HERE 映射 JS API v3 集群提供程序挂起,添加许多数据点
- Ajax 调用挂起在 jQuery 中
- writeln img src将数据提交到外部系统-Firefox和IE挂起
- 在jQuery中,.state()如何确定一个承诺是挂起的、已解决的还是被拒绝的
- 为什么JavaScript中没有挂起回调函数
- SP2007使IE在运行jssor代码时挂起
- 如何解决量角器测试无限期挂起的问题?