Paul Toone
Paul Toone

Reputation: 143

How click button in CasperJS

I can't figure out how to click this button with CasperJS. So far, I've been using thenClick and searching for the link with a[href=''] but I can't do that for this button. It shows this when I inspect the element of the button:

<a style="float"href="javascript:void(0)"onclick="$('#divNewSection').slideToggle()">add...</a>

Upvotes: 0

Views: 1016

Answers (1)

Artjom B.
Artjom B.

Reputation: 61892

There are many ways to click that link. You have to find a unique way to address it.

For example:

  1. casper.click("a[style='float']")

  2. casper.click("a[style='float'][onclick*='.slideToggle()']")

  3. casper.click('a[onclick="$(\'#divNewSection\').slideToggle()"]')

  4. casper.click(x("//a[text()='add...']")) where var x = require('casper').selectXPath;

Upvotes: 1

Related Questions