1
I want to do a test using Casperjs. I want him to click the login button.
I have the following menu:
<ul id="menu-top">
<li class="0 first"><a title="" href="/empresa">Empresa</a></li>
<li class="1"><a title="" href="/plano-de-negocio">Plano de Negócio</a></li>
<li class="2"><a title="" href="/produtos">Produtos</a></li>
<li class="3"><a title="" href="/contato">Contato</a></li>
<li class="4 last"><a title="" href="login.php">Área restrita</a></li>
</ul>
To click I used the following code:
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});
casper.start('http://localhost/teste');
casper.then(function(){
this.click('.4.last>a');
});
casper.run();
But the following error returns to me:
[error] [remote] findAll(): invalid selector provided ". 4.last>a":Error: SYNTAX_ERR: DOM Exception 12
Caspererror: Cannot Dispatch mousedown Vent on nonexistent selector: . 4.last>a
I’m using firepath to find the css path of the button (.4.last>a)
Maybe he didn’t like that it starts with number. Tried
li.4.last>a
?– bfavaretto
Yes, I tried that too. this.click('li.4.last>a');
– ralfting