javascript - Casper: Getting error Cannot dispatch mousedown event on nonexistent selector -
trying click on link using below code. getting error @ code this.click('/login')
me solve able click on link struck.
i output :
fail cannot dispatch mousedown event on nonexistent selector: /login # type: uncaughterror # file: loki1.js:1355
here code:
casper.test.begin('signin loki',1,function(test){ casper.start('http://localhost:3000'); casper.evaluate(function() { __utils__.echo("hello world!"); }); casper.wait(100,function(){ casper.echo("debuging"); casper.echo("this:"+this); casper.echo("done"); if (this.exists('headerwrap')) { casper.echo('the heading exists'); } this.click('/login'); ////this not working this.fill('#loginform', { 'login' : 'divya', 'password' : '********' }, false);
this html
what selector should use click on href=/login
<div class="navbar-collapse collapse" id="main-navbar-collapse"> <ul class="nav navbar-nav navbar-right"> <li> <a href="/login" data-toggle="tooltip" data-placement="bottom" data-original-title="login">sign in</a> </li> </ul> </div>
there multiple ways believe. use jquery click on it, href , open page href, or need change value inside click.
jquery .click() , .prop()
to click jquery this:
casper.evaluate(function(){ jquery('.nav.navbar-nav.navbar-right li a').click() });
you href html so:
var link = casper.evaluate(function(){ return jquery('.nav.navbar-nav.navbar-right li a').prop('href'); });
this return '/login' , casper.thenopen((your url)+link))
casper.click()
i think need different value inside this.click(); believe need this.click('#main-navbar-collapse > ul > li > a');
of may need changed based on html have elsewhere, should point in right direction.
Comments
Post a Comment