I'm trying to use CasperJS as a web scraper, and there's a page with buttons that will load data when clicked. So, I'd like to click all of these buttons first and wait before actually making a query to grab all the necessary data.
The problem is that with Casper, casper.thenClick(selector) clicks the first element. But how do you iterate and click each element based on the selector?
Note that these buttons do not have ids. They all have generic class selectors.
Ex.
<h3>
<span>Text 1</span>
<span>
<button class="load-btn">show</button>
</span>
</h3>
<h3>
<span>Text 2</span>
<span>
<button class="load-btn">show</button>
</span>
</h3>
<h3>
<span>Text 3</span>
<span>
<button class="load-btn">show</button>
</span>
</h3>
And for some reason casper.thenClick("h3:contains('text 1') .load-btn") doesn't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With