How to click a “select option” and then evaluate loaded content with casperjs

后端 未结 9 1415
长情又很酷
长情又很酷 2021-01-02 01:46

I\'m trying to crawl the sizes for this product:

Link to product

The problem: The sizes are loaded after the color of the product is selected.

In th

9条回答
  •  一生所求
    2021-01-02 02:07

    I don't know if you found a solution to your problem, but here is how I would solve it:

    casper.click('#color');
    casper.then(function() {
    casper.waitFor(function check() {
      return this.evaluate(function() {
        return document.querySelector('select.select-category').selectedIndex === 2; 
      });
    }, function then() {
         /* do the rest that you would want to do!*/
       });
    
    }
    

提交回复
热议问题