量角器测试用例在竹子上运行时冻结

时间:2016-12-13 10:31:52

标签: node.js testing protractor bamboo browser-automation

当我在Visual Studio上运行测试时,我的测试成功运行。但是当我尝试在竹子上运行它时,我的浏览器冻结,我的测试因茉莉花超时异常而失败。

请找到我的量角器配置文件:

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporters = require('jasmine-reporters');
var co = require('co');

// Example usage:
//      protractor --env=local
//      protractor --env=local --specs=test/road/road-missing.js

var reporter = new HtmlScreenshotReporter({
    dest: 'target/screenshots',
    filename: 'Test_Report.html',
    fixedScreenshotName: true
});

var junitReporter = new reporters.JUnitXmlReporter({
    savePath: 'target/screenshots',
    consolidateAll: false
});


var customReporter = {
    specStarted: function(result) {
        console.log('\n---------------- Spec started: ' + result.fullName + ' ----------------');
    }
}


var FUNCTION_CONFIG = {

    beforeLaunch: function () {
        return new Promise(function (resolve) {
            reporter.beforeLaunch(resolve);
        });
    },
    onPrepare: function () {
        // cleanup of a failed test, generating an alert: "You have unsent changes."
        // This will log the error:
        // UnexpectedAlertOpenError: unexpected alert open: {Alert text : You have unsent changes.}
        afterEach(co.wrap(function*() {
            browser.ignoreSynchronization = true;
            // force leaving page by open page about:blank
            yield browser.get("about:blank");
            try {
                // if no alert is shown an exception is thrown. This is the case if a test finished successful
                var alert = yield browser.switchTo().alert();
                yield alert.accept();
            } catch (e) {
                // case: no alert was shown. accessing alert will trhow an exception, which can be ignored
            }
        }));

        browser.manage().window().setSize(480, 900);

        jasmine.getEnv().addReporter(reporter);
        var jasmineReporters = require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
            consolidateAll: true,
            savePath: 'target/screenshots',

            filePrefix: 'xmloutput'
        }));
        jasmine.getEnv().addReporter(customReporter);
    },

    afterLaunch: function (exitCode) {
        return new Promise(function (resolve) {
            reporter.afterLaunch(resolve.bind(this, exitCode));
        });
    }
};


function extend(obj, source) {
    if (source) {
        for (var prop in source) {
            if (typeof obj[prop] === "object" && !Array.isArray(obj[prop]))
                extend(obj[prop], source[prop]);
            else
                obj[prop] = source[prop];
        }
    }
    return obj;
};


function getArgv(parameter) {
    var argv = process.argv;
    var param = parameter + "=";
    for (var i = 0; i < argv.length; i++) {
        if (argv[i].startsWith(parameter))
            return argv[i].substring(param.length);
    }
    return undefined;
}

var DEFAULT_CONFIG = require('./env/default.js');

var env = getArgv('--env') || 'local';
var ENV_CONFIG = require('./env/' + env + '.js');

var conf = extend(FUNCTION_CONFIG, DEFAULT_CONFIG);

exports.config = extend(
    conf,
    ENV_CONFIG
);

这也是浏览器失败的测试用例之一:

var UI = require('./../ui.js');
var co = require('co');
var ui = new UI();
describe("MapFeedback: address-infowrong", function () {
    ui.setSmallScreenSize();
    // ui.testLogger(100);
    it("test", co.wrap(function* () {
        yield browser.get(ui.createAddressStartLink());
        yield ui.ADDRESS_PROBLEM.click();
        var version = yield browser.executeScript('return mapfeedbackVersion');
        console.log("Map feedback Version:" + version);
        expect(browser.getCurrentUrl()).toContain("report_address");
        yield ui.ADDRESS_INFO_WRONG.click();
        expect(browser.getCurrentUrl()).toContain("select_address_edit/address_edit");
        yield ui.zoomIn(18.5);
        var elmOK = element(By.css('button[ng-click="doneSelectObject(selectedObject)"]'));
        yield ui.waitFor(protractor.ExpectedConditions.elementToBeClickable(elmOK));
        yield elmOK.click();
        expect(browser.getCurrentUrl()).toContain("address_edit");

        yield element(by.xpath("/html/body/div[1]/div/div/div[2]/div[2]/div[1]/div[1]/input")).click();
        yield element(by.xpath("//*[@id=\"input_addressNumber\"]")).sendKeys("TEST");
        yield element(by.xpath("    /html/body/div[1]/div/div/div[2]/div[2]/div[4]/div[1]/input")).click();
        yield element(by.xpath("//*[@id=\"input_address_other\"]")).sendKeys("TEST");
        yield ui.SUBMIT.click();
        expect(browser.getCurrentUrl()).toContain("submit");

        yield ui.waitSubmit();
        var reportId = yield browser.executeScript('return mapFeedBack.reportId');
        console.log("address-infowrong id: " + reportId);
        expect(yield element(By.css('div[ng-show="mapFeedBack.submitState==\'success\'"]')).isDisplayed()).toBeTruthy();

        var req = yield ui.getMapFeedbackData(-reportId);
        var body = JSON.parse(req.body);
        console.log(body);
        expect(body.properties.error).toEqual(21);
        expect(body.properties.details).toEqual("Other address issue: TEST");

    }));
});

注意:我正在使用selenium网格进行测试自动化。

// --- config: default

module.exports = {
    params: {
        baseUrl: "NOT-SET",
        urlParams: "zoomLevel=15",
        urlParamCoords: "55.67653,12.56040", // Copanhagen Location
        urlAddressParamCoords: "40.75170,-73.99420", //New York Location,

        rest: {
            baseUrl: "NOT-SET",

            header: {
                //  'Content-Type':     'application/vnd.here.layerObjectList+json; charset=UTF-8',
                'Auth-Identifier': 'Y-7Wnc2lNk3fMI0n3-rZ',
                'Auth-Secret': 'mEv_DZ1JKDDYzESUAp9KyQ',
                'Auth-Service-Id': 'here_app',
                'User-Agent': 'mapfeedback-test',
                'Accept': 'application/vnd.here.layerObject+json',
                'Group-Id': 'FGx1AWaAzKOo0imNkLmf'
            }
        }
    },
    seleniumAddress: "http://selenium.community.nw.ops.here.com:4444/wd/hub",


    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome',
        maxInstances: 1
    },

    // Framework to use. Jasmine is recommended.
    framework: 'jasmine',

    // Spec patterns are relative to the current working directly when protractor is called.
    specs: [
        // Note: group & sort tests by feature  
        './test/address/address-remove.js',
        './test/address/address-missing.js',
        './test/address/address-infowrong.js',


        './test/border/border-linemissing.js',
        './test/border/border-linedrawnwrong.js',

        './test/other/other-cartoincorrect.js',
        './test/other/other-cartomissing.js',
        './test/other/other-cartoremove.js',

        './test/place/place-closed.js',
        './test/place/place-offensivecontent.js',
        './test/place/place-violateprivacy.js',
        './test/place/place-Inappropriatebehaviour.js',
        './test/place/place-otherviolation.js',
        './test/place/place-copyright.js',
        './test/place/place-otherissue.js',
        './test/place/place-missing.js',
        './test/place/place-infowrong.js',

        './test/road/road-missing.js',
        './test/road/road-closed.js',
        './test/road/road-infowrong.js',

        './test/satellite/satellite-conflictimage.js',
        './test/satellite/satellite-obscuredimage.js',
        './test/satellite/satellite-oldimage.js',
        './test/satellite/satellite-unclearimage.js',
    ],


    // Options to be passed to Jasmine.
    jasmineNodeOpts: {
        defaultTimeoutInterval: 50000
    }
};

请帮忙??

0 个答案:

没有答案