-2

The following is HTML:

<div class="graph_tit" id="graph_tit">
<a href="/jsp/home/contents/climateData/smart/smartStatisticsSearch.do" class="on" onclick="return false;">관측자료</a> 
<a href="/jsp/home/contents/climateData/smart/smartStatisticsSearch.do" onclick="return false;" class="">통계자료</a> 
</div>

I want to select the second a element in CasperJS.

But, <a> nodes are similar.

The following is tried code in CasperJS.

$('div[id="graph_tit"] a[class=""]').click();

$('div[id="graph_tit"] a[text()="통계자료"]').click();
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • 1
    Which is the one and How do you want to select? – Satpal Jun 02 '15 at 06:19
  • 통계자료 – ARong Kwon Jun 02 '15 at 06:24
  • 1
    If alexce's answer doesn't help you (and it should), then there is a problem somewhere else. Please register to the `resource.error`, `page.error`, `remote.message` and `casper.page.onResourceTimeout` events ([Example](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf)). Maybe there are errors. – Artjom B. Jun 02 '15 at 08:29

1 Answers1

0

You can check that the class attribute is empty:

this.click('div.graph_tit a[class=""]');

You may also need to wait for the selector:

this.waitForSelector('div.graph_tit a[class=""]').thenClick('div.graph_tit a[class=""]');
Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195