Commit 3622f3e2 3622f3e238fa92a3da882b4e10dd6d48230a5987 by Nicolas Perriault

better documentation for Casper#fill

1 parent b962f381
Showing 1 changed file with 18 additions and 1 deletions
...@@ -372,15 +372,32 @@ casper.start('http://www.google.fr/', function(self) { ...@@ -372,15 +372,32 @@ casper.start('http://www.google.fr/', function(self) {
372 372
373 Fills the fields of a form with given values and optionnaly submit it. 373 Fills the fields of a form with given values and optionnaly submit it.
374 374
375 Example: 375 Example with this sample html form:
376
377 ``` html
378 <form action="/contact" id="contact-form" enctype="multipart/form-data">
379 <input type="text" name="subject"/>
380 <textearea name="content"></textearea>
381 <input type="radio" name="civility" value="Mr"/> Mr
382 <input type="radio" name="civility" value="Mrs"/> Mrs
383 <input type="text" name="name"/>
384 <input type="email" name="email"/>
385 <input type="file" name="attachment"/>
386 <input type="checkbox" name="cc"/> Receive a copy
387 <input type="submit"/>
388 </form>
389 ```
376 390
377 ```javascript 391 ```javascript
378 casper.start('http://some.tld/contact.form', function(self) { 392 casper.start('http://some.tld/contact.form', function(self) {
379 self.fill('form#contact-form', { 393 self.fill('form#contact-form', {
380 'subject': 'I am watching you', 394 'subject': 'I am watching you',
381 'content': 'So be careful.', 395 'content': 'So be careful.',
396 'civility': 'Mr',
382 'name': 'Chuck Norris', 397 'name': 'Chuck Norris',
383 'email': 'chuck@norris.com', 398 'email': 'chuck@norris.com',
399 'cc': true,
400 'attachment': '/Users/chuck/roundhousekick.doc'
384 }, true); 401 }, true);
385 }).then(function(self) { 402 }).then(function(self) {
386 self.evaluateOrDie(function() { 403 self.evaluateOrDie(function() {
......