defunctzombie/zuul

Access wd `browser` in tests

Closed this issue · 7 comments

I am running a bunch of selenium tests through saucelabs. Is it possible to access the browser object? From the wd library? I see you use it to set up the selenium stuff. I want to be able to do things like:

browser
  .title()
    .should.become('WD Tests')
  .elementById('i am a link')
  .click()
  .eval("window.location.href")
    .should.eventually.include('guinea-pig2')
  .back()
  .elementByCss('#comments').type('Bonjour!')
  .getValue().should.become('Bonjour!')
  .fin(function() { return browser.quit(); })
  .done();

in my tests, which is in the wd docs

vvo commented

@saulshanabrook I think this is not the goal of zuul. It's not a selenium test runner on multiple browsers, it's a tape/mocha/jasmine test runners on multiple browsers.

For what you want to do, you do not need zuul at all indeed you can just use wd directly in nodejs scripts and connect to saucelabs.

Then if you want to run your script in multiple browsers, that's just a matter of doing a small test runner on your side.

Also, for what you want to do you just need a library that runs client side and mimics those calls. Since all the tests are already running in a browser environment, you don't actually need the browser object, you already in a browser!

You can just do document.querySelector(..) ... etc!

@defunctzombie Yeah. I was thinking about doing it that way, but wd just provides some nice wrappers around things like filling in forms and clicking buttons. Do you know of any good client side libraries that would fill a similar niche?

@vvo Yeah I see how this isn't a common use case for zuul, but it seems to be a nice option for these tests because it allows me to easily to test in multiple browsers. I don't really see a problem with using tape to do these integration type tests. Tape is just a test running, it is agnostic to what the meat of the tests actually are. I like how simple tape is.

@saulshanabrook don't know anything off the top of my head but I am almost certain there is something out there. If not.. maybe a nice opportunity :)

@defunctzombie I thought so too, but everything I can find is bundled together with a whole test running or other stuff. I guess I can just use raw DOM/jquery.

Yea. Also you might get some mileage out of this:
https://github.com/defunctzombie/synthetic-dom-events

And go from there :)

I think you could put together a compelling little client side only lib and everyone would benefit!

@defunctzombie Thanks! that looks like a great start. I will let you know if I turn any of it into a library :)