Permalink
Browse files

Basic testing framework

  • Loading branch information...
sergeychernyshev committed Nov 14, 2014
1 parent 89463d5 commit 556a59eb5aa093e64ba63e83d76a5647b5d23c07
Showing with 68 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +13 −0 Makefile
  3. +14 −0 package.json
  4. +38 −0 tests/test.js
View
@@ -4,3 +4,6 @@ tags
cache
.phptidy-cache
.DS_Store
node_modules
tests/run/
nohup.out
View
@@ -77,3 +77,16 @@ apigen:
code:
php phptidy/phptidy.php replace
find . -name '*.phptidybak~' | xargs -n10 rm
test: cleantest runtests
runtests:
nohup phantomjs --webdriver=4444 --cookies-file=tests/run/cookies.txt &
sleep 1
-node tests/test.js http://howdoable.lc/users/ tests/run/
-killall phantomjs
open tests/run/*.png
cleantest:
rm -rf tests/run/
rm -f nohup.out
View
@@ -0,0 +1,14 @@
{
"name": "StartupAPI",
"author": "Sergey Chernyshev",
"version": "0.1.0",
"devDependencies": {
"webdriverio": "~2.3.0",
"phantomjs": ">=1.8"
},
"repository": {
"type": "git",
"url": "git@github.com:StartupAPI/users.git"
}
}
View
@@ -0,0 +1,38 @@
// Use webdriverjs to create a Selenium Client
var client = require('webdriverio').remote({
desiredCapabilities: {
// You may choose other browsers
// http://code.google.com/p/selenium/wiki/DesiredCapabilities
browserName: 'chrome'
},
// webdriverjs has a lot of output which is generally useless
// However, if anything goes wrong, remove this to see more details
logLevel: 'silent'
});
var base_url = process.argv[2];
var run_images = process.argv[3];
var screenshot_prefix = 'login_page';
var screenshot_index = 0;
client.init()
.addCommand("record", function(cb) {
var image_file = run_images + '/' + screenshot_prefix + (screenshot_index++) + '.png';
this.saveScreenshot(image_file).call(cb);
})
.addCommand("login", function(url, user, pw, cb) {
this.url(url)
.record()
.setValue('#startupapi-usernamepass-username', user)
.setValue('#startupapi-usernamepass-pass', pw)
.record()
.submitForm('#startupapi-usernamepass-username')
.pause(3000)
.call(cb);
})
.setViewportSize({width: 1280, height: 1024}, false)
.login(base_url + '/login.php', 'sergeychernyshev', 'bogus')
.record()
.url(base_url + '/edit.php')
.record()
.end();

0 comments on commit 556a59e

Please sign in to comment.