Henley Wing Chiu
Henley Wing Chiu

Reputation: 22535

How to test if selector exists in CasperJS?

I know I can use:

casper.test.assertExists(#selector);

But I want to actually store if it exists in a boolean variable.

I.e. something like this:

var exists = SelectorExists(#selector);

Upvotes: 16

Views: 10383

Answers (1)

Henley Wing Chiu
Henley Wing Chiu

Reputation: 22535

I just found out:

if(!casper.exists('#selector')){
   #selector doesn't exist
}

Upvotes: 31

Related Questions