jqueryruby-on-railscucumberwatirfirewatir

FireWatir and jQuery


after using this excellent peace of software called FireWatir, I wonder if there is a way to integrate jQuery-selector-magic to my test.

My first attempt is to use firewatir's js_eval() method like this

require 'rubygems'
require 'firewatir'
f = FireWatir::Firefox.new
f.js_eval("alert(42);")

The only thing I get is a

JsshSocket::JSReferenceError: alert is not defined

which is kind of strange because other expressions like

f.js_eval("document.location.toString();")

Work like a charm!

Anyone with a hint?

Thanks and greets,

Joe


Solution

  • Okay folks,

    i got jQuery working with a lot of researching and I hope this will be help you out if you have similar problems:

    firefox.js_eval("var target = getWindows()[0]; target.content.jQuery('#selector').toggle()")
    

    What i had to do was to select the window I am working in explicitly and within its content jQuery is available and one is able to use all of its awesomeness! ;)

    Greetings Joe