protractor - Angular e2e test page object initialize before all tests -
here folder structure:
|-- test |-- unit |-- e2e |--suita testa.js |--suitb testb.js |--helper helper.js
in helper functions:
var helper = function() { console.log('load helper module'); this.listh3title = element.all(by.css('div.col-sm-3 h3')).first().gettext(); this.firstresponsivetable = element(by.css('div.responsive-table')); }; module.exports = helper;
in testa.js
describe('testa:', function() { browser.get(''); it('login form should present', function() { var loginform = element(by.css('form[name="loginform"]')); expect(loginform.ispresent()).tobetruthy(); }); });
in testb.js
var helper = require('../utilities/helper'); var helper = helper = new helper(); describe('testb:', function() { });
the helper function run before tests. in case testa fail because can't find element
Comments
Post a Comment