How to wait for a click() event to load in phantomjs before continuing?

后端 未结 3 1577
夕颜
夕颜 2020-12-14 19:48

Phantomjs has these two really handy callbacks onLoadStarted and onLoadFinished which allow you to essentially pause execution while the page is lo

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-14 20:08

    Use the high-level wrapper, nightmarejs. You can easily click there and wait afterwards.

    Here is the code (Examples section):

    var Nightmare = require('nightmare');
    new Nightmare()
      .goto('http://yahoo.com')
        .type('input[title="Search"]', 'github nightmare')
        .click('.searchsubmit')
        .run(function (err, nightmare) {
          if (err) return console.log(err);
          console.log('Done!');
        });
    

    More examples and API usage can be found at github

提交回复
热议问题