Below shows how I ran Waitr on Linux (Fedora Core 5), attached to a browser via url, navigated to one url and then navigated back.
First of we need a version of FireFox with JSSH installed in it. I only managed this with a build from source.
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot login
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk
cd mozilla
make -f client.mk checkout MOZ_CO_PROJECT=browser
cvs up -r ZAP_20050610_BRANCH extensions/jssh
cat > .mozconfig
=== snip
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/fx-jssh
ac_add_options --enable-extensions=default,jssh
=== end snip
make -f client.mk build
Then I waited, in fact I went out shopping, because it takes a while on my Athlon XP 2700+. Once it did complete I fired up firefox and did a quick sanity test to check connectivity with jssh.
./fx-jssh/dist/bin/firefox -jssh
$> telnet localhost 9997
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Welcome to the Mozilla JavaScript Shell!
Now to get FireWatir up and going.
Get the latest version of watir from svn, then get the firefox branch.
svn co http://svn.openqa.org/svn/watir/trunk
svn co http://svn.openqa.org/svn/watir/branches/firefox
Copy the firefox version over the normal version.
cp -r firefox/code/* trunk/watir/I ran this quick little example
$LOAD_PATH << '/home/ivan/work/firewatir/firewatir/mix'
require 'watir'
include Watir b = Firefox.new()
b.attach(:url, 'http://www.groklaw.net/')
b.goto('http://xtra.co.nz')
b.goto('http://www.groklaw.net')With this unfortunate output :(
$ ruby browsertest.rb
/home/ivan/work/firewatir/firewatir/mix/watir/win32ole/win32ole.so: /home/ivan/work/firewatir/firewatir/mix/watir/win32ole/win32ole.so: invalid ELF header - /home/ivan/work/firewatir/firewatir/mix/watir/win32ole/win32ole.so (LoadError)
from /home/ivan/work/firewatir/firewatir/mix/watir.rb:141
from browsertest.rb:5
Not suprisingly the stuff that ties into Windows' COM objects didn't want to work on Linux so I then hacked watir.rb and made these changes:
--- firefox/code/watir.rb 2006-07-04 13:33:12.000000000 +1200
+++ mix/watir.rb 2006-07-11 22:52:56.000000000 +1200
@@ -138,10 +138,11 @@
# Use our modified win32ole library
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'watir', 'win32ole')
-require 'win32ole'
+mswin = /mswin/ =~ RUBY_PLATFORM
+require 'win32ole' if mswin
require 'logger'
-require 'watir/winClicker'
-require 'watir/WindowHelper'
+require 'watir/winClicker' if mswin
+require 'watir/WindowHelper' if mswin
require 'watir/exceptions'
require 'container'
@@ -478,9 +479,12 @@
private :attach_browser_window
# this will find the IEDialog.dll file in its build location
- @@iedialog_file = (File.expand_path(File.dirname(__FILE__)) + "/watir/IEDialog/Release/IEDialog.dll").gsub('/', '\\')
- @@fnFindWindowEx = Win32API.new('user32.dll', 'FindWindowEx', ['l', 'l', 'p', 'p'], 'l')
- @@fnGetUnknown = Win32API.new(@@iedialog_file, 'GetUnknown', ['l', 'p'], 'v')
+
+ if /mswin/ =~ RUBY_PLATFORM
+ @@iedialog_file = (File.expand_path(File.dirname(__FILE__)) + "/watir/IEDialog/Release/IEDialog.dll").gsub('/', '\\')
+ @@fnFindWindowEx = Win32API.new('user32.dll', 'FindWindowEx', ['l', 'l', 'p', 'p'], 'l')
+ @@fnGetUnknown = Win32API.new(@@iedialog_file, 'GetUnknown', ['l', 'p'], 'v')
+ end
def self.attach_modal(title)
hwnd_modal = 0
And re-ran the example and watched firefox wander its merry way around the internet :)
Hopefully more to follow...
UPDATE:
After all that fun I found this page
http://people.mozilla.com/~davel/jssh/ though I haven't tried it yet this should cut out a lot of effort.
Labels: misc