I've seen and tried many incantations of js eval in the various Watir's out there. firewatir for ffox, as well as safariwatir. In firefox, I got things working but need Safari as my project is webkit based. For example, in the firefox version I can do stuff like:
@browser.document.parentWindow.eval('window.resizeTo(800,600)')
In any event, my question is there any equivalent to js_eval, execute_script, or access to document and/or window objects from the Watir::Safari object? I would like to do things like clear the local storage, etc.
EDIT:
Went ahead and used watir-webdriver
require "rubygems"
require "watir-webdriver"
#browser = Watir::Browser.new :ie
#browser = Watir::Browser.new :firefox
@browser = Watir::Browser.new :chrome
@browser.goto "http://google.com"
@browser.text_field(:name, 'q').set "watir-webdriver"
@browser.button(:name, 'btnG').click
@browser.div(:id => "resultStats").wait_until_present
puts "Displaying page: '#{@browser.title}' with results: '#{@browser.div(:id => "resultStats").text}'"
@browser.execute_script('alert("hi");')
Chrome is webkit based, and works with Watir-Webdriver. More importantly to the user, security wise it is not as porous as chickenwire. (there's a reason Safari has an unblemished record for the last 4 years running as the first browser to fall at pwn2own.) Chrome also has (depending on what source you want to believe) between 2.5 to 6 times the market share that Safari does.
If you need a webkit based browser, why not use chrome?
I'm not kidding about the security aspect either, one security expert I happen to know with a published textbook on how to do security testing has said "The only good use for Safari is to download Firefox or Chrome"