当运行时间增加时,量角器测试速度会减慢

时间:2015-05-11 13:46:42

标签: selenium-webdriver protractor

我目前在一个套件中有一套量角器测试,需要大约45分钟到1个小时才能完成。随着测试的进展,我注意到每次测试的运行时间都在严重增加。

以下代码是我在spec.js文件中执行的测试:

$('select').on('change', function() {
    var results = {};

    $('select').each(function() {
        var val = $(this).val();
        if (val) {
            results[val] = (results[val] || 0) + 1;
        }
    })

    console.log(results);
});

我不确定在for-loop中编写所有这些是不好的做法,但我无法想象这是否与性能下降有关。开始时,for循环中的每个测试大约需要15-20秒。在测试整个循环时,我遇到了规范超时,迫使我将以下代码添加到我的conf.js中:

for (var i = 0; i < users.length; i++){
    (function(test){

        it('Should load the team page', function(){
            teamPage.loadTeamPage();
        });
        it('Should create a credential with a team', function(){
            teamPage.createCredentialWithTeam(test, 'Test Team');
        });
        it('Should create a schedule with a team', function(){
            teamPage.createScheduleWithTeam(test, 'Test Team');
        });
        it('Should create a task with a team', function(){
            teamPage.createTaskWithTeam(test, 'Test Team');
        });
        it('Should edit a team', function(){
            teamPage.editTeamByName(test, 'Test Team', 'New Test Team','Testing Department', true);
        });
        it('Should add a team member', function(){
            teamPage.addTeamMember(test, 'Test Team', 'foo', 'Admin', true);
        });
        it('Should load the department page', function(){
            departmentPage.loadDepartmentPage();
        });
        it('Should edit a department', function(){
            departmentPage.editDepartmentByName(test, 'Testing Department', 'Testing Department Edited', 'non', true);
        });
        it('Should view a department', function(){
            departmentPage.viewDepartmentByName('Testing Department')
        });
        it('Should add a departmentmember', function(){
            departmentPage.addDepartmentMember(test, 'Testing Department', 'foo', 'Admin', true);
        });
        it('Should load the organisation page', function(){
            organisationPage.loadOrganisationPage();
        });
        it('Should add a department', function(){
            organisationPage.addDepartment(test, 'Test Department Protractor', 'Test Case Organisation', true, true);
        });
        it('Should attempt to add members to an organisation', function(){
            organisationPage.addOrganisationMember(test, 'Test Case Organisation', 'foo', 'Admin', true);
        });
        it('Should check the organisation and compare the details with the view page', function(){
            organisationPage.viewOrganisationByName('Test Case Organisation');
        });
        it('Should try to edit an organisations details', function(){
            organisationPage.editOrganisation(test, 'Test Case Organisation', 'Edited Test Case Organisation');
        });
        it('Should log out', function(){
            HomePage.logout();
        });
    })(users[i]);
}

这会将默认超时值30000(ms)增加到60000(ms)。量角器与浏览器交互的速度也在视觉上降低。 我已经读过在每次测试之前启动WebDriver的新实例,但这似乎是运行时的整体增加。

编辑:以下内容也让我想到了:我有一个附加到此过程的jasmine2的html-screenshot-reporter,它在每次测试后捕获屏幕截图,它是否有可能缓存这些图像中的每一个并且这会累积测试本身会对主机系统造成一些压力吗?

有没有人遇到与量角器类似的问题? 任何意见都表示赞赏。如果您需要更多信息,请不要犹豫。

干杯

0 个答案:

没有答案