Last active
August 29, 2015 14:27
-
-
Save eyalzek/b9f0bc87ab25162495a1 to your computer and use it in GitHub Desktop.
This file contains 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
// run with: TEST_ENV=prod2 ./node_modules/.bin/mocha --timeout 99999 simplified.js | |
var webdriverio = require('webdriverio'), | |
mocha = require('mocha'), | |
assert = require('assert'), | |
q = require('q'), | |
env = process.env.TEST_ENV, | |
url = env ? 'https://' + env + '-env.showbox.com/workspace.html' : 'https://showbox.com/workspace.html'; | |
var client = webdriverio.remote( | |
{ | |
desiredCapabilities: {browserName: 'chrome'}, | |
logLevel: 'verbose' | |
} | |
); | |
client.addCommand('login', function(cb) { | |
console.log(url); | |
return this.url(url) | |
.waitForExist('.login-panel', 10000) | |
.waitUntil(function() { | |
return client.getAttribute('.login-panel', 'class').then(function(attr) { | |
console.log(attr); | |
return (attr.indexOf('active') !== -1); | |
}); | |
}, 5000).then(function(result) { | |
return this.pause(2000) | |
.addValue('#user_email', 'formatcheck@showbox.com') | |
.addValue('#user_password', "1234") | |
.click('.submit-login'); | |
}); | |
}); | |
client.addCommand('clearShow', function() { | |
return this.url(url) | |
.waitForVisible('.icon-bin23', 5000) | |
.click('.icon-bin23') | |
.pause(1000) | |
.waitForVisible('.btn.btn-danger.deleteEpisode', 5000) | |
.click('.btn.btn-danger.deleteEpisode') | |
.pause(2000); | |
}); | |
// take a look here: https://github.com/webdriverio/webdriverio/issues/273 | |
client.addCommand('clearShows', function() { | |
var funcs = [click, secondClick], | |
clicks = [], | |
click = function(el) { | |
return client.pause(1000).elementIdClick(el.ELEMENT); | |
}, | |
secondClick = function(el) { | |
return client.waitForVisible('.deleteEpisode', 5000).click('.deleteEpisode'); | |
}; | |
return this.url(url) | |
.waitForVisible('.icon-bin23', 5000) | |
.elements('.icon-bin23').then(function(result) { | |
assert(result, 'no elements found'); | |
result.value.forEach(function(el) { | |
clicks.push(funcs.reduce(q.when, q(el.ELEMENT))) | |
}); | |
// .elementIdClick(el) | |
// .waitForVisible('.btn.btn-danger.deleteEpisode', 5000) | |
// .click('.btn.btn-danger.deleteEpisode'); | |
}); | |
// return p; | |
return q.all(clicks); | |
// }); | |
}); | |
describe('test', function() { | |
before(function(done){ | |
client.init(done); | |
}); | |
it('should login', function() { | |
return client | |
.login() | |
.waitForVisible('.dashboard-wrapper', 20000) | |
.saveScreenshot('login.png'); | |
}); | |
it('should logout', function() { | |
return client | |
.clearShows(); | |
}); | |
after(function(done) { | |
client.end(done); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment