How to fire click event on multiple targets returned via browser.queryAll(".class")

399 views
Skip to first unread message

Zac Morris

unread,
Nov 25, 2013, 1:45:00 PM11/25/13
to zomb...@googlegroups.com
I'm a bit stuck.

I have a set of elements that all have the class ".expandable", that I would like to click.

var Browser = require("zombie");
var assert = require("assert");

function fireOnAll(browser,action,selector,callback){
   var elements = browser.queryAll(selector);
   for (var e=0;e<elements.length;e++){
     browser.fire(action,elements[e]);
   }
   browser.wait(callback);
}

browser = new Browser()
browser
  .on("error", function(error){
    console.error(error);
  })
  .visit("http:/localhost", function() {
    fireOnAll(browser,"click",".expandable",function(){
      console.log("The page:",browser.html());
      browser.close();
      process.exit();
    })
  })

This throws an invalid target error, so I'm guessing it has something to do with converting the results of browser.queryAll(selector), to an appropriate target for the fire call.

Anyone point me in the right direction?

THANKS!
-Zac

Zac Morris

unread,
Nov 25, 2013, 2:13:08 PM11/25/13
to zomb...@googlegroups.com
OK, found the problem.

Either there is a bug, or the documentation is wrong...

Documentation:

browser.fire(name, target, calback?)


Actual:

browser.fire(target, name, calback?)

Jonah Werre

unread,
Feb 21, 2014, 3:52:33 PM2/21/14
to zomb...@googlegroups.com
 You're right, it looks like the documentation is wrong. It should be:

browser.fire(target, name, calback?)

Reply all
Reply to author
Forward
0 new messages