我正在尝试在量角器\轴上编写可访问性自动测试。
测试用例:
1)打开网址
2)开始第一张幻灯片
3)斧头分析
4)下一张幻灯片
5)重复3-4
这是我测试的一部分
const excelbuilder = require('msexcel-builder');
const moment = require('moment');
const AxeBuilder = require('axe-webdriverjs');
const COLS = require('./../report-builder/lcomColumn').cols();
const workbook = excelbuilder.createWorkbook('reports', 'lcom_report' +
moment(new Date()).format('hh_mm_ss__DD-MM-YY') + '.xlsx');
const sheet1 = workbook.createSheet("sheet1", Object.keys(COLS).length, 65536);
let row = 2;
describe('Accessibility testing', () => {
beforeAll(() => {
let col;
for (col in COLS) {
if (col !== undefined) {
sheet1.set(COLS[col], 1, col);
}
}
});
afterAll(() => {
workbook.save((err) => {
if (err) {
console.log('======> Failed to save a WORKBOOK.');
throw err;
} else {
console.log('======> WORKBOOK has been saved.');
}
});
});
describe('Protractor Demo App', function () {
it('slide vwr', function () {
(async () => {
const startButton = element(by.className('play-button'));
const nextSlide = element(by.className('fa fa-arrow-right'));
browser.get(`local url`);
const EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(element(by.className('play-button')), 5000));
startButton.click();
const slides = element(by.className('counter'));
const getmaxslides = await slides.getText().then(function (text) {
const counts = +text.split('/')[1];
return counts;
});
const builder = AxeBuilder(browser.driver);
for (let slide = 0; slide < getmaxslides; slide++) {
builder.analyze(results => {
results.violations.forEach(v => {
const nodes = [];
v.nodes.forEach(node => {
nodes.push(node.html.substring(0, 250));
});
sheet1.set(COLS.file_name, row,);
sheet1.set(COLS.slide_num, row, slide + 1);
sheet1.set(COLS.violations, row, results.violations.length);
sheet1.set(COLS.rule_id, row, v.id);
sheet1.set(COLS.impact, row, v.impact);
sheet1.set(COLS.description, row, v.description);
sheet1.set(COLS.tags, row, v.tags);
sheet1.set(COLS.nodes_html, row, nodes.join(','));
row++;
});
});
nextSlide.click();
}
})();
});
});
});
我有160个模型(每个模型上约有30张幻灯片)。我使用此代码来测试可访问性。
但是在某些型号上,我有问题。
我已经在尝试更改defaultTimeoutInterval,但问题仍在发生。
这是日志的一部分:
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
Accessibility testing
Protractor Demo App
× slide vwr
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:469:11)
at tryOnTimeout (timers.js:304:5)
- WebDriverError: no such session
(Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 10.0.10240 x86_64)
最佳答案
在规范中添加了超时解决了这个问题
describe('Protractor Demo App', function () {...} , timeout_in_millis)
关于javascript - Protractor +轴心错误 Jasmine .DEFAULT_TIMEOUT_INTERVAL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47980898/