最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

量角器+ ax

运维笔记admin11浏览0评论

量角器+ ax

量角器+ ax

我正在尝试在量角器\ ax上编写辅助功能自动测试。测试用例:

1)打开URL

2)开始第一张幻灯片

3)Ax分析

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)
回答如下:

在spec中添加超时解决了这个问题

describe('Protractor Demo App', function () {...} , timeout_in_millis)

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论