Created
August 9, 2015 16:56
-
-
Save koriaf/089e0bb7acc6fc4891fc to your computer and use it in GitHub Desktop.
dalek.js example of website register test (with pre-logout and post-logout to ensure that no any 302 redirect will be used for registration form page)
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
BASE_URL = "URL HERE"; | |
module.exports = { | |
'Register test': function (test) { | |
REGISTER_URL = BASE_URL + '/profile/register/'; | |
test_user_data = { | |
'username': 'test_user' + Math.round(Math.random() * 10000 + 10000), | |
}; | |
test | |
.open(BASE_URL + '/profile/logout/') | |
.waitForElement("div#top") | |
.assert.url(BASE_URL) // assuming that logout redirects to index page | |
.open(REGISTER_URL) | |
.waitForElement("form#form_reg") | |
.assert.title().to.contain('Sign Up') | |
.type('#last_name', 'Lastname') | |
.type('#first_name', 'Firstname') | |
.type('#middle_name', 'Middlename') | |
.type('#id_login', test_user_data.username) | |
.type('#id_password1', 'password1') | |
.type('#id_password2', 'password1') | |
.type('#email', test_user_data.username + "@test.some.domain") | |
.click('#submit_registration_form_button') | |
.waitFor(function(){ | |
return Boolean(document.querySelector('#some_unique_indentificator_of_success_page')); | |
}, [], 3000) | |
.screenshot("dalek/screenshots/after_register.png") | |
.open(BASE_URL + '/profile/logout/') // dalek saves cookies for next tests, so, we logout to avoid side-effects | |
.done() | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment