Last active
December 2, 2015 21:21
-
-
Save ObjectIsAdvantag/3823bc252921f3bbc630 to your computer and use it in GitHub Desktop.
Horseman UI testing sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* UI testing with Horseman (phantomjs node integration) | |
* | |
* Installation | |
* see http://www.horsemanjs.org/ | |
* | |
* Run | |
* node <this-file.js> | |
* | |
* Debugging | |
* set DEBUG to horseman to get insight about what's going on | |
* | |
* Trace sample | |
horseman .setup() creating phantom instance on +0ms | |
horseman .setup() phantom instance created ok. +872ms | |
horseman .setup() creating phantom page. +3ms | |
horseman .setup() phantom page created ok. +22ms | |
horseman .setup() setting viewport. +2ms | |
horseman .setup() viewport set ok. +10ms | |
horseman .opening: http://restlet.com/products/apispark/ +37ms | |
horseman load finished, injecting jquery and client scripts +6s | |
horseman .open: http://restlet.com/products/apispark/ - status: success +4ms | |
horseman jQuery not injected - already exists on page +7ms | |
horseman .click() a#apispark_signin_1 +113ms | |
horseman .waitForSelector() div.a0-notloggedin.a0-mode +2s | |
horseman .type() [email protected] into input[name="email"] +63ms | |
horseman .type() XXXXXXXX into input[name="password"] +123ms | |
horseman .click() button.a0-primary.a0-next +63ms | |
horseman .waitForSelector() a.dropdown-toggle.ng-binding +7s | |
horseman .url() +2ms | |
horseman .evaluate() fn on the page +59ms | |
horseman .close(). +3ms | |
* | |
*/ | |
var horsemanModule = require("node-horseman"); | |
// Increase timeout from 5s to 20s so that APISpark home can load | |
var horseman = new horsemanModule ({ 'timeout' : 20000 }); | |
var result = horseman.open('http://restlet.com/products/apispark/') | |
.click('a#apispark_signin_1') | |
// wait for auth0 div to by displayed | |
.waitForSelector('div.a0-notloggedin.a0-mode') | |
// login via a test account (rather than a social provider) | |
.type('input[name="email"]','[email protected]') | |
.type('input[name="password"]','XXXXXXXX') | |
.click('button.a0-primary.a0-next') | |
// wait to dashboard to appear | |
.waitForSelector('a.dropdown-toggle.ng-binding') | |
.url(); | |
horseman.close(); | |
console.log(result); | |
// => https://apispark.restlet.com/dashboard | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment