Last active
December 17, 2015 01:59
-
-
Save asciidisco/5532050 to your computer and use it in GitHub Desktop.
Test login in embedded iframe that is also protected by http auth
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
module.exports = { | |
// name of the suite | |
name: 'some super secret project login test', | |
// Can log in @portal, go to dashbaord, and can go further from there | |
'can log in @portal': function (test) { | |
'use strict'; | |
test.expect(3) | |
.setHttpAuth('username', 'password') | |
.open('https://some.super.secret.domain.com/super/path/') | |
.assert.title('SECRET > Login', 'Login page title is correct') | |
.waitForElement('#login-iframe') | |
// iframes can only be selected by their index by now, | |
// this should be changed to accpet a selector expression | |
.toIframe(0) | |
.val('#email', '[email protected]') | |
.val('#passwd', 'password') | |
.click('input[name="submit-btn"]') | |
.end() | |
.assert.title('SECRET > Dashboard', 'Dashbaord page title is correct') | |
.waitForElement('a[href="/chpt/my-portal/settings/"]') | |
.click('a[href="/super/path/settings/"]') | |
.assert.title('SECRET > settings', 'Can open settings from dashbaord') | |
.done(); | |
}, | |
// Get rejected when logging in @portal with wrong credentials, | |
// get redirected to the login again and verify that the user receives an error message | |
'get rejected when logIn with wrong credentials @portal': function (test) { | |
'use strict'; | |
test.expect(4) | |
.setHttpAuth('username', 'password') | |
.open('https://some.super.secret.domain.com/super/path/') | |
.assert.title('SECRET > Login', 'Login page title is correct') | |
.waitForElement('#login-iframe') | |
.toIframe(0) | |
.val('#email', '[email protected]') | |
.val('#passwd', 'baz') | |
.click('input[name="submit-btn"]') | |
.end() | |
.assert.title('SECRET > Login', 'Login page title is shown when trying to log in with wrong credentials') | |
.toIframe(0) | |
.waitForElement('.error-msg') | |
.assert.chain() | |
.visible('.error-msg', 'Error message is visible') | |
.text('.error-msg', 'Credentials are wrong.', 'Error message has the correct text') | |
.end() | |
.end() | |
.done(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment