How to test if selector exists in CasperJS?

Henley Chiu picture Henley Chiu · Sep 3, 2012 · Viewed 10.2k times · Source

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);

Answer

Henley Chiu picture Henley Chiu · Sep 3, 2012

I just found out:

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