Skip to content

Instantly share code, notes, and snippets.

@thom4parisot
Created July 12, 2012 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thom4parisot/3098134 to your computer and use it in GitHub Desktop.
Save thom4parisot/3098134 to your computer and use it in GitHub Desktop.
Bootstrap Dropdown CasperJS check.
casper.start();
casper.open('http://twitter.github.com/bootstrap/javascript.html#dropdowns');
casper.then(function(){
this.test.assertExists('#navbar-example');
this.click('#dropdowns .nav-pills .dropdown:last-of-type a.dropdown-toggle');
this.wait(2000, function(){
this.test.assertExists('#dropdowns .nav-pills .open', 'Dropdown is open');
});
});
casper.run(function(){
this.test.done();
});
@n1k0
Copy link

n1k0 commented Jul 12, 2012

Chez moi https://gist.github.com/3098134/bdb02729e77809fe66cdf71ee98f48914ac136a6 marche:

Test file: c.js                                                                 
PASS Found an element matching #navbar-example
PASS Dropdown is open
PASS 2 tests executed, 2 passed, 0 failed.    

@thom4parisot
Copy link
Author

Test file: casper.js                                                            
PASS Found an element matching #navbar-example
FAIL Dropdown is open
#    type: assertExists
#    subject: false
#    selector: "#dropdowns .nav-pills .open"
FAIL 2 tests executed, 1 passed, 1 failed. 

@n1k0
Copy link

n1k0 commented Jul 12, 2012

Petite refacto:

casper.start('http://twitter.github.com/bootstrap/javascript.html#dropdowns', function() {
  this.test.assertExists('#navbar-example');
  this.click('#dropdowns .nav-pills .dropdown:last-of-type a.dropdown-toggle');
  this.waitUntilVisible('#dropdowns .nav-pills .open', function() {
    this.test.pass('Dropdown is open');
  });
});

casper.run(function() {
  this.test.done();
});

@n1k0
Copy link

n1k0 commented Jul 12, 2012

T'utilises quelle version d'ailleurs ?

@thom4parisot
Copy link
Author

livarot:~ oncletom$ casperjs --version
1.0.0-RC1

livarot:~ oncletom$ phantomjs --version
1.6.0

@naholyr
Copy link

naholyr commented Jul 12, 2012

Tu mens, @n1k0 !

@thom4parisot
Copy link
Author

Solved in CasperJS master. Related to https://github.com/n1k0/casperjs/issues/153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment