I've a login-spec.js like below:
describe('user should login with given credentials', function() {
beforeEach(function() {
browser.waitForAngular();
});
it('Get page title', function() {
browser.driver.getTitle().then(function(text){console.log(text);});
expect(browser.getTitle()).toEqual('abc','therefore Passed');
});
it('login registered user', function() {
loginpage.enterUsername('username');
loginpage.enterPassword('password');
loginpage.loginBtn().click();
browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then
(function(url) {
return (/homepage/).test(url);
});
});
expect(browser.getCurrentUrl()).toContain(baseurl+'/homepage');
});
Now i want to do some action on the homepage, like say click on a web element. The code of homepage is in a different spec say homepage-spec.js
describe('homepage', function() {
beforeEach(function() {
browser.waitForAngular();
});
it('click guest list', function() {
homepage.guestlist().click();
});
Now would i be required to write the login page code and login the user in homepage spec? Would it be possible to call the login-spec.js code in homepage-spec.js and execute it? like when i give
protractor conf.js --suite homepage-spec.js
The browser opens with the login page and logs in displaying the homepage on which the displayed web element is clicked.