Skip to content

Instantly share code, notes, and snippets.

@artjomb
Created January 25, 2015 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artjomb/e8ac639985af50471441 to your computer and use it in GitHub Desktop.
Save artjomb/e8ac639985af50471441 to your computer and use it in GitHub Desktop.
the selector as copied from chrome is
'#fx_form > table > tbody > tr:nth-child(11) > td > table > tbody > tr > td:nth-child(4) > a'
so I want to click this link.. but if I run
[debug] [phantom] found it
[debug] [phantom] No
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="fx_form">
<table>
<tbody>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td>
<table>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td>
<a href="fdfsdf">hello</a>
</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
</div>
</body>
</html>
var casper = require('casper').create();
var fff = '#fx_form > table > tbody > tr:nth-child(11) > td > table > tbody > tr > td:nth-child(4) > a';
casper.start('file:///home/user/simple.html', function() {
});
casper.waitForSelector(fff, function(){
this.log("found it")
if(this.exists(fff)){
this.log("yes");
} else {
this.log("No");
}
}).run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment