Skip to content

Instantly share code, notes, and snippets.

@jcheype
Last active August 29, 2015 14:01
Show Gist options
  • Save jcheype/85d7dabc23ca5d43ffe3 to your computer and use it in GitHub Desktop.
Save jcheype/85d7dabc23ca5d43ffe3 to your computer and use it in GitHub Desktop.
system = require('system')
host = system.env.VULCAIN_PORT_8080_TCP_ADDR
port = system.env.VULCAIN_PORT_8080_TCP_PORT
screenshot = casper.cli.get('screenshot') || 'error.png';
url = casper.cli.get('host') || 'http://'+host+':'+port;
casper.echo("## "+url)
casper.userAgent('CASPERJS TEST');
casper.options.onWaitTimeout = -> casper.capture(screenshot)
casper.on('remote.message', (message) ->
casper.echo("## "+message)
)
casper.test.begin('Go to vulcain home page, login and logout', 6, (test) =>
casper.start(url, =>
casper.viewport(1280, 1024)
test.assertTitle("Vulcain", "Vulcain homepage title is the one expected")
test.assertExists('#login-button', "login button is found")
test.assertNotVisible('#authenticationLogin', "login is not visible")
casper.click('#login')
)
casper.then(=>
test.assertVisible('#authenticationLogin', "authenticationLogin field is visible")
test.assertVisible('#authenticationPassword', "authenticationPassword field is visible")
casper.sendKeys('#authenticationLogin', 'njancot')
casper.sendKeys('#authenticationPassword', 'failpassword')
casper.click('#login-button')
casper.waitForText("Problème d'authentification", (=>) , => test.fail("Error login not shown"))
)
casper.then(=>
casper.sendKeys('#authenticationPassword', 'njancot', {reset: true})
casper.click('#login-button')
casper.waitUntilVisible('#logout-button')
)
casper.then(=>
test.assertVisible('#logout-button', "logout button is visible")
)
casper.run(-> casper.capture(screenshot); test.done() )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment