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.
click
function from the outer context into the page context. This didn't work with PhantomJS 1.x. Did this change? I would be quite surprised if this really works as you describe it. – Aloud