small refactorization of ClientUtils#setField
Showing
1 changed file
with
12 additions
and
8 deletions
... | @@ -248,8 +248,8 @@ | ... | @@ -248,8 +248,8 @@ |
248 | * placeholer names: | 248 | * placeholer names: |
249 | * | 249 | * |
250 | * casper.evaluate(function() { | 250 | * casper.evaluate(function() { |
251 | * document.querySelector('#username').setAttribute('value', '%username%'); | 251 | * document.querySelector('#username').value = '%username%'; |
252 | * document.querySelector('#password').setAttribute('value', '%password%'); | 252 | * document.querySelector('#password').value = '%password%'; |
253 | * document.querySelector('#submit').click(); | 253 | * document.querySelector('#submit').click(); |
254 | * }, { | 254 | * }, { |
255 | * username: 'Bazoonga', | 255 | * username: 'Bazoonga', |
... | @@ -672,27 +672,31 @@ | ... | @@ -672,27 +672,31 @@ |
672 | case "input": | 672 | case "input": |
673 | var type = field.getAttribute('type') || "text"; | 673 | var type = field.getAttribute('type') || "text"; |
674 | switch (type.toLowerCase()) { | 674 | switch (type.toLowerCase()) { |
675 | case "text": | ||
676 | case "password": | 675 | case "password": |
677 | default: | 676 | case "text": |
678 | field.setAttribute('value', value); | 677 | case "textarea": |
678 | field.value = value; | ||
679 | break; | 679 | break; |
680 | case "checkbox": | 680 | case "checkbox": |
681 | field.setAttribute('checked', value ? "checked" : ""); | 681 | field.setAttribute('checked', value ? "checked" : ""); |
682 | break; | 682 | break; |
683 | case "file": | ||
684 | console.log("file field filling is not supported"); | ||
685 | break; | ||
683 | case "radio": | 686 | case "radio": |
684 | field.click(); | 687 | field.click(); |
685 | break; | 688 | break; |
689 | default: | ||
690 | console.log("unsupported field type: " + type); | ||
691 | break; | ||
686 | } | 692 | } |
687 | break; | 693 | break; |
688 | case "textarea": | ||
689 | field.innerText = value; | ||
690 | break; | ||
691 | case "select": | 694 | case "select": |
692 | console.log('select tag fillin not implemented'); | 695 | console.log('select tag fillin not implemented'); |
693 | break; | 696 | break; |
694 | default: | 697 | default: |
695 | console.log('unsupported field type: ' + type); | 698 | console.log('unsupported field type: ' + type); |
699 | break; | ||
696 | } | 700 | } |
697 | } | 701 | } |
698 | }; | 702 | }; | ... | ... |
-
Please register or sign in to post a comment