//var url='http://localhost:8080/F81_EwmFrontendWebClient';
var url = 'http://localhost:8080/F81_EwmFrontendWeb-DEMO/#/';
var username='DEMO1';
loginModule = require("login");
//casper.options.logLevel = 'debug'; //60 seconds for each step to complete it self.
// casper.options.verbose = true;
casper.test.begin('test goto myWealth page', 1, function suite(
test) {
casper.start(url, function() {
this.echo(url);
this.echo(this.getTitle());
this.test.assertTitle('UBS Beta');
loginModule.doLogin(username);
// your test code beign
loginModule.doNavTo(username,'myWealth');
});
})
casper.run(function() {
this.test.done(); // I must be called once all the async stuff has been executed
this.test.renderResults(true, 0, 'log-02.xml');
});
var require = patchRequire(require);
function doLogin(username) {
console.log(username);
casper.then(function() {
console.log('begin to login as user :' + username);
casper.waitForSelector('input[name="loginID"]', function() {
casper.test.comment('do login');
this.sendKeys('input[name="loginID"]', username);
this.capture('screenshots/' + username + '/01-login.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
this.click('button#viewLogin-loginButton');
});
});
casper.wait(1000, function() {
if (casper.exists('p#view2faLogin-insutruction')) { //DEMO USER SKIP THIS
casper.waitForSelector('p#view2faLogin-insutruction', function() {
casper.test.comment('do faLogin access card');
this.echo(this.getHTML('p#view2faLogin-insutruction'));
this.sendKeys('input#view2faLogin-accessCode1', '12');
this.sendKeys('input#view2faLogin-accessCode2', '34');
this.sendKeys('input#view2faLogin-accessCode3', '56');
this.sendKeys('input#view2faLogin-accessCode4', '78');
this.capture('screenshots/' + username + '/02-acesss-card.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
this.click('button#view2faLogin-clickLogin');
});
}
});
casper.wait(1000, function() {
//this.echo(this.getHTML('div#elag_content_zone'));
this.capture('screenshots/' + username + '/03-agrrentment.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
this.click('button#ElagButton-accept');
casper.test.comment('do accept agrrentment');
});
casper.wait(10000, function() {
this.echo(this.getCurrentUrl());
if (casper.visible('button.buttonupdate')) {
this.capture('screenshots/' + username + '/05-homepage-update.png', {
top: 0,
left: 0,
width: 1024,
height: 768
})
this.click('button.buttonupdate');
casper.test.comment('do close update');
}
if (casper.exists('label#skipVirtualTour')) {
this.capture('screenshots/' + username + '/05-1-VirtualTour.png', {
top: 0,
left: 0,
width: 1024,
height: 768
})
this.click('label#skipVirtualTour');
casper.test.comment('do close VirtualTour');
}
});
casper.wait(1000, function() {
if (casper.visible('div.demo-window')) {
this.capture('screenshots/' + username + '/05-2-homepage-with-tips.png', {
top: 0,
left: 0,
width: 1024,
height: 768
})
this.click('div.demo-close-button');
casper.test.comment('do close homepage tips');
}
})
casper.wait(10000, function() {
this.capture('screenshots/' + username + '/05-homepage.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
})
}
exports.doLogin = doLogin;
function doNavTo(username, pageID) {
var nav_id;
switch (pageID) {
case 'settings':
nav_id = 'settings';
break;
case 'myWealth':
nav_id = 'myWealth';
break;
case 'help':
nav_id = 'help';
break;
}
casper.wait(1000, function() {
casper.test.comment('nav to pageID:' + pageID);
this.click('span#menuIcon');
});
casper.waitForSelector('common-mainmenu-item#' + nav_id, function() {
this.click('common-mainmenu-item#' + nav_id + '>li');
// this.capture('screenshots/' + username + '/06-homepage-submenu.png', {
// top: 0,
// left: 0,
// width: 1024,
// height: 768
// });
})
casper.wait(6000, function() {
this.echo(this.getCurrentUrl());
this.capture('screenshots/' + username + '/' + nav_id + '.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
})
//body end
}
exports.doNavTo = doNavTo;