Filling complex forms with Casperjs

150 views
Skip to first unread message

Lorenzow

unread,
Mar 30, 2015, 9:58:16 AM3/30/15
to casp...@googlegroups.com
Hi,

I use Casperjs for task automation and have to fill a form with PickUp Date, DropOff Date and PickUp Location.

Filling PickUp Date and DropOff Date works just fine. (i can check this with screenshot).

When you start filling the fied PickUp Location , a list of choices is build based on what you typed.
This list is displayed inside <ul class="ct-autocomplete ct-ui-base" id="ui-id-1" ....></ul>

So i tried to use: this.waitUntilVisible('u#ui-id-1', function() 
But I get the following error:

[warning] [phantom] Casper.waitFor() timeout
FAIL "u#ui-id-1" never appeared in 10000ms
#    type: uncaughtError
#    error: "u#ui-id-1" never appeared in 10000ms
#    stack: not provided

Thanks for your help
Lorenzow


casper.start(url, function() {
});

casper
.then(function() {
 
this.waitForResource(this.getCurrentUrl(),function() {


   
//Filling Pick Up Date    
   
this.click('input#ct_s1_pickup_date');
   
this.fill('form#ct_s1_frm_search', {
 
'ct_pickup_date':   '05/04/2015'
   
},false);
   
   
//Filling Drop Off Date
   
this.click('input#ct_s1_dropoff_date');
   
this.fill('form#ct_s1_frm_search', {
 
'ct_dropoff_date':   '15/04/2015'
   
},false);
   
   
this.capture('screenshot step1.png');
       
 
},function() {
 
},5000);
});


casper
.then(function() {
   
   
//Filling Pick Up Location
   
this.click('input#ct_s1_pickup_loc');
   
this.fill('form#ct_s1_frm_search', {
       
'ct_pickup_loc':    'Barcelone'
   
},false);
   
   
this.echo(this.getHTML('ul#ui-id-1', true));
   
   
this.waitUntilVisible('u#ui-id-1', function() {
   
this.capture('screenshot step3.png');
   
});
});


casper
.evaluate(function(){
 
});


casper
.run(function() {
   
this.exit();
});




Tim Scott

unread,
Mar 30, 2015, 11:12:25 AM3/30/15
to casp...@googlegroups.com, Lorenzow
I would try sendKeys instead of fill. I guess maybe fill is not triggering whatever event that makes the dropdown visible. If it still doesn’t work, I would go into evaluate and blur the textbox.


-- 
Tim Scott

--
CasperJS homepage & documentation: http://casperjs.org/
CasperJS @github: https://github.com/n1k0/casperjs
 
You received this message because you are subscribed to the Google Groups "casperjs" group.
Visit this group at http://groups.google.com/group/casperjs?hl=en.
---
You received this message because you are subscribed to the Google Groups "CasperJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages