Thank you! Your feedback has been delivered
Thank you! Your feedback has been sent

How to Login by filling the form in CasperJs

Following is the hlml of the login form that I have

<div class="login_area_user">

            <form method="post" action="https://www.tradus.com/login?dest_url=https://www.tradus.com/cart/select-address" id="user-login">
            <input type="hidden" value="1" name="form_submit">

                <h3 style="display:inline-block;">Already a Member</h3>

                <p id="login-main-center-right-descp">You can use tradus login id and password</p>

                <div class="login-row">
                    <label class="colorBlack">Email / Login*</label>
                    <input class="login-field" type="text" name="name" id="edit-namepopup">
                </div> <!-- [/login-row] -->

                <div class="login-row">
                    <label>Password</label>
                    <input class="login-field" type="password" id="edit-passpopup" name="pass">
                </div> <!-- [/login-row] -->

                <div class="login-row">            
                    <a class="forgotPassword" href="/forgot_password">Forgot your password?</a>
                    <!--input type="checkbox" name="remember" /><span>Remember me</span-->
                </div>

                <div class="login-row">
                    <input class="login-button" value="Login" type="submit">
                </div>

                <input type="hidden" name="op" value="Log in">

            </form>

        </div>

Am using the following code to login :

this.fill('form#user-login', {
        'form_submit':    1,
        'name':    'abc@gmail.com',
        'pass':   'pwd',
        'op':       'Log in'

    }, true);

But its not logging

User Gravatar

user352

Posted Sep 9 2013 11:49 UTC

$5


  • casperjs
  • 7433 Views

5 Replies


can you show the line above this.fill?

User Gravatar

guyisra

Posted Sep 9 2013 12:13 UTC

casper.waitForSelector('#login-main', function() {

this.fill('form#user-login', {
        'form_submit':    1,
        'name':    'abc@gmail.com',
        'pass':   'xxxx',
        'op':       'Log in'

    }, true);

});
User Gravatar

user352

Posted Sep 9 2013 12:57 UTC

does this work?

casper.start('https://www.tradus.com/login?dest_url=https://www.tradus.com/cart/select-address', function() {
this.fill('form#user-login', {
        'form_submit':    1,
        'name':    'abc@gmail.com',
        'pass':   'xxxx',
        'op':       'Log in'

    }, true);

});
User Gravatar

guyisra

Posted Sep 9 2013 13:01 UTC

No...

How can i make a post request for the same and send a post instead of fill()

User Gravatar

user352

Posted Sep 9 2013 13:41 UTC

can you do it on another url and form?

User Gravatar

guyisra

Posted Sep 9 2013 17:22 UTC

Add a reply

By posting a reply on CodersClan you agree to our Terms & Conditions