Need help
I am scraping data from this website which has a form that contains three selectlists interconnected to each other that is if the any option from the from the first select list is selected this function is called onchange="Javascript:submitForm2();
and the second selectlist is populated.
And subsequently if an option from the second selectlist is selected the same js function is called onchange="Javascript:submitForm2();"
And finally two submit buttons for this form each call different js function which populate the result. So I checked out the docs and I did not find any info about selectlists.
Three dynamically changing select lists interconnected to each other
<select name="s1" onChange="Javascript:submitForm2();" style="width: 150px" width="150">
<select name="s2" onChange="Javascript:submitForm2();" style="width: 300px" width="300">
<select name="s3" style="width:300px" width="300">
And the form has two submit buttons
Tried with these codes this.click('select#s1 option[value="26"]'); this.debugHTML();
Gives me this error CasperError: Cannot dispatch click event on nonexistent selector: select#s1 option[value="26"]
I also tried document.querySelector('select[name="s1"]').setAttribute('value', "26");
Which gives TypeError: 'null' is not an object (evaluating'document.querySelector('select[name="s1"]').setAttribute')
Sharing the solution script. I Iterated upon the select lists
n*n*n
times along with dates and two buttons.You can do something like this you have a form with three interconnected selects.
If you context page includes jQuery library, this code could be different (smaller and cleaner).
Here there is example using casperjs and jQuery with dynamic selectlists.
CasperJs and Jquery with chained Selects