blob: 9acf2aa0b6ef0d17fecbea8acf8a3fdde64ecfdc [file] [log] [blame]
Matteo Scandolod3b57a12017-04-20 14:33:04 -07001const fs = require('fs');
2const config = require('./config');
3const P = require('bluebird');
4
5const username = 'xosadmin@opencord.org';
6
7const getPwd = () => {
8
9 if (process.env.UI_PWD) {
10 return process.env.UI_PWD;
11 }
12
13 const pwdFile = fs.readFileSync('../../build/platform-install/credentials/xosadmin@opencord.org', 'utf8');
14 return pwdFile;
15};
16
17exports.pwd = getPwd();
18
19exports.username = username;
20
21exports.login = P.promisify((done) => {
22 browser.get(`${config.url}/login`);
23
24 browser.getCurrentUrl()
25 .then((url) => {
26 // NOTE login only if it is not yet
27 if (url.indexOf('login') !== -1) {
28 const loginPage = require('../login/login.po');
29 loginPage.sendUsername(username);
30 loginPage.sendPassword(getPwd());
31 loginPage.submit();
32 }
33 browser.waitForAngular();
34 done();
35 });
36});