在异步模式下运行量角器跳过我的测试用例

时间:2015-12-17 16:33:18

标签: javascript angularjs selenium local-storage protractor

我正在运行量角器来测试支持多个语言环境(ar / en)的Web应用程序,我需要通过浏览器从localStorage获取语言键,然后获取该语言的json文件(在节点上下文中)。 问题是量角器没有看到我的任何测试用例。这是代码段。

/**
 * This variable must be included in all protractor e2e specs test
 */
var basePath = process.cwd();
var localStorage = require(basePath + '/test/helpers/localStorage');
var locale = require(basePath + '/test/helpers/locale');
/**
 * scenarios
 */
var testScenarios = function () {
    var cityLabel = element(by.linkText(locale.tr.call(locale, 'City')));
    it('test translation on label', function () {
        // check for labels
        cityLabel.getText().then(value, function () {
            expect(value).toEqual("City");
        });
    });
    /**
     *
     */

    it('test update company information', function () {
        update();
        expect(browser.getLocationAbsUrl()).toMatch("/login");
    });
};
/**
 *
 */
describe('Profile page', function () {
    // got to profile
    browser.get(ENV.Protractor.BASE_URL + '#/profile/');
    // get the current language key
    localStorage.getValue("NG_TRANSLATE_LANG_KEY").then(
        /**
         *  Init local dictionary object
         * @param value, current language key
         */
        function (value) {
            // 
            locale.init.call(locale, value);
        }
    )
        // I need that all tests will executed after locale initialisation
    .then(testScenarios);
});

0 个答案:

没有答案