Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does CasperJS form submit not redirect to the next page?

This is my first casper test, so I'm still struggling with the basics. I would like to fill in the username and password on my login form, then submit it. And then confirm if a 'log off' link is rendered on the next page (confirming that the user has been logged in).

But as far as I can tell, when then is called, the url is still the same. Looks like no post or redirect to the next page is happening. What am I doing wrong?

casper.start "http://test.local.mycompany.local/", ->
    @echo 'at ' + @getCurrentUrl()
    @fill 'form', { UserAlias : 'joe', Password : 'password' }, true

casper.then ->
    @echo 'at ' + @getCurrentUrl()
    @test.assertExists '#log-off-link', 'log-off link exists'

casper.run ->
    @test.done()

So the echo of @getCurrentUrl both returns the same URL, which is wrong.

like image 304
willem Avatar asked Aug 29 '12 15:08

willem


1 Answers

You can try to use chrome extension ressurectio to generate automated tests, for casperjs, in browser. It's very simple to use and useful. May be in a few lines(- part of generated code) you should to make some fixes but anyway it's very useful and convenient.

like image 183
Александр Кривошеев Avatar answered Nov 15 '22 14:11

Александр Кривошеев