FireWatir and jQuery

after using this excellent software called FireWatir, I am wondering if there is a way to integrate jQuery-selector-magic into my test.

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

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

The only thing I get is

JsshSocket :: JSReferenceError: Undefined warning

which is strange because other expressions like

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

Work like a charm!

Anyone with a clue?

Thank you and welcome

Joe

+3
source share
3 answers

Good,

jQuery, , , , :

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

, , . jQuery , !;)

+1

, , $, , .

var win = new getWindows()[0].content;
var doc = browser.contentDocument;

$ = function(selector) {

  win.content.jQuery(selector, doc);

}

- chicago

+2

FireWatir Wiki:

FireWatir JavaScript, JSSh DOM , .

alert window , DOM . , , window.alert('hello dollly').

FireWatir JSSh, js_eval DOM, window.

0

Source: https://habr.com/ru/post/1733012/


All Articles