Challenge with fill method sometimes submitting...

14 views
Skip to first unread message

phil...@yahoo.com

unread,
Oct 26, 2016, 9:04:25 PM10/26/16
to CasperJS
Hi:
I am creating a UI test and a simple Logon is not consistently working.
My data is in the following json file:
{
 "baseUrl": "http://localhost:20000/",
 "userName": "TestUser",
 "passWord": "Abc1234!",
 "loginForm": "form#loginForm"
}

My logon code is in is own code file:
var loginConfig = require('./loginPage.json');
function Login() {
    LoginWith(loginConfig.userName, loginConfig.passWord);
}
function LoginWith(userName, passWord) {
    casper.thenOpen(loginConfig.baseUrl, function OnToDoHomePage() {
        this.waitForSelector(loginConfig.loginForm);
    });
    casper.then(function EnterTestUserNameAndPassword() {
        var ret = this.fill(loginConfig.loginForm, {
            'UserName': userName,
            'Password': passWord
        }, true);
    });
}

The following casper properly submits the form:
casper.test.begin('Testing ToDo Logon', function(test) {
    ...
    casper.start();
    casper.then(function LoginWithGood() {
        Login();
    });
    ...
});

The following casper does not submits the form:
casper.test.begin( 'Testing ToDo Logon Failure', function(test) {
    ...
    casper.start();
    casper.then( function LoginAsBadUser() {
        LoginWith( 'TestUser', 'badpassword' );
    });
    ...
});

I capture after the failure to submit the form an the user name and password are filled in the respective input filed, but the page appears to not submitted.

Phil

LoginErr.png

phil...@yahoo.com

unread,
Oct 29, 2016, 12:49:24 PM10/29/16
to CasperJS
Hi All:

Solved it. Just added a delay
        this.wait(500);
after the fill.  Allow for the service to respond.  Unfortunately I cannot figure anything that would be any differently on the page to wait for ...

Phil

Ken

unread,
May 25, 2017, 4:01:55 PM5/25/17
to CasperJS
That's true.. Sometime it is not even whether some text is visible or not. Some delay is usually good after interacting with some elements or filling form. Also, some fields have validation events which add a bit of delay before the next step can be done properly.
Reply all
Reply to author
Forward
0 new messages