Watch it fly!
Below is an example of a basic single page AngularJS application.
Switch to a wider screen to see the demo in action!
Press the "Take Off" button
Full example
// configuration (set viewport size, pace)
// optional
flythru.config({
viewport:{
w: 320, h: 568
}
});
// set your website page
// mandatory prior to adding tests!
flythru.destination("../index.html");
// First test aka Flight!
// each Flight has stops and layovers
// inside stops and layovers are pass, fail and cargo
// 'pass' is a function to call to continue to next stop
// 'fail' throws error and grounds flight
// 'cargo' is a cached object that shares data between stops,flights, layovers
// and gives you access to your websites window object. There is also
// a toolbox which has helper functions. seen below.
// You are free to use 'cargo' to pass data between your flights,
// stops or layovers :)
flythru.addFlight("Login")
.addStop("Enter Credentials - admin/pass123", function(pass,fail,cargo){
var uInput = $(cargo.win.document).find('[name="username"]');
var pInput = $(cargo.win.document).find('[name="password"]');
if(uInput.length > 0 && pInput.length > 0){
cargo.toolbox.angular.applyValue(uInput[0],"admin");
cargo.toolbox.angular.applyValue(pInput[0],"pass123");
pass();
}else{
fail('Unable to fill in credentials');
}
})
.addStop("Click login",function(pass,fail,cargo){
var found = $(cargo.win.document).find('button:contains("Login")');
if(found.length) { found.click(); pass(); }
else { fail("No login button found"); }
}).
layover("Records ready?",function(pass,fail,cargo){
var found = $(cargo.win.document).find('.contacts-table');
if(found.length && found.is(":visible")){
pass();
}
});
// edit
flythru.addFlight("Find and Edit Ted")
.addStop("Search for Ted",function(pass,fail,cargo){
cargo.passenger = {
fname: "Ted", lname: "Schmity"
}
var found = $(cargo.win.document).find("[ng-model='searchParam']");
if(found.length){
cargo.toolbox.angular.applyValue(found[0],
cargo.passenger.fname);
pass();
}else{
fail("Could not find search box!");
}
})
.layover("Is Ted there?",function(pass,fail,cargo){
var found = $(cargo.win.document)
.find('.contacts-table td:contains("'+cargo.passenger.fname+'")');
if(found.length){
cargo.ele = found; pass();
}
},5000)
.addStop("Click the Ted row", function(pass,fail,cargo){
cargo.ele.click(); pass();
})
.layover("Wait for Ted's details", function(pass,fail,cargo){
var foundLabel = $(cargo.win.document).find('.detail-pane label:contains("Name:")');
if(foundLabel.length){
var match = foundLabel
.parent()
.text()
.indexOf(cargo.passenger.fname+" "+cargo.passenger.lname) > 0;
if(match) pass();
}
},5000)
.layover(2000) // wait so you can read the details, for effect only
.addStop("Close the details", function(pass,fail,cargo){
var found = $(cargo.win.document)
.find('.detail-pane footer button');
if(found.length){
found.click();
(!found.is(":visible"))?pass():fail('Details did not close!');
}
});
// logout
flythru.addFlight("Logout")
.layover(1000)
.addStop("Click the logout button",function(pass,fail,cargo){
var found = $(cargo.win.document).find("[ng-click='logout()']");
if(found.length){
found.click(); pass();
}else{
fail("No logout button found!");
}
})
.layover("Are we at login screen?",function(pass,fail,cargo){
var found = $(cargo.win.document).find('[name="username"]');
if(found.length && found.is(":visible")) pass();
},4000)