Hi Angrez,
 
Using firefox, I've gone to the URL below
 
http://rubyforge.org/cgi-bin/viewcvs.cgi/*checkout*/watir/watir/rexml/element.rb?root=wtr&rev=1.1
 
then selected Save Page As ...
 
then browsed to C:\ruby\lib\ruby\1.8\rexml
 
I got prompted to confirm I want to over-write; I selected Yes
 
I did the same for functions.rb.
 
For watir.rb I saved to C:\ruby\lib\ruby\site_ruby\1.8 (I've also tried C:\ruby\lib\ruby\1.8 just in case I got the wrong location). When I ran my test script I still got
 
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1922:in `elements_by_xpath': undefined method `elements' for nil:NilClass (NoMethodError)
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1912:in `element_by_xpath'
        from G:/workspace/web_pages/trial.rb:3
 
With nothing to lose, I've tried running install.rb. Here's the output
 
C:\Temp\watir>install.rb
C:\Temp\watir\watir.gif
Going to install to C:\watir\ with startMenu=1 and desktop=1
Copying Files
watir.rb -> c:\ruby\lib\ruby\site_ruby\1.8/watir.rb
cp -r watir c:\ruby\lib\ruby\site_ruby\1.8
cp -r examples C:\watir\
cp -r unitTests C:\watir\
cp -r doc C:\watir\
cp -r rdoc C:\watir\
Rdoc not installed
Creating start menu shortcuts
Creating desktop shortcuts
Installation Completed
 
The revision of watir.rb is 1.282
 
I still get the same error message when I run my test script.
 
What version of Ruby are you running?
 
Regards
 
Chris
-----Original Message-----
From: Angrez Singh [mailto:[EMAIL PROTECTED]
Sent: Friday, March 03, 2006 12:08 AM
To: [email protected]
Subject: Re: [Wtr-general] xpath support doesn't work for me

Hi Chris,

require 'watir'
ie = Watir::IE.start("http://localhost/index.asp")
ie.element_by_xpath("//[EMAIL PROTECTED]'top_menu_map']/area[contains(@href , 'signup.htm')]/").click
The browser opens to the correct page but I get the following error
 
web_pages>ruby trial.rb
C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1922:in `elements_by_xpath': undefined method `elements' for nil:NilClass (NoMethodError)
        from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1912:in `element_by_xpath'
        from trial.rb:5

One thing I noticed is that when you install 'watir' using 'watir_installer.exe' located in 'installer' folder it install wrong version of 'watir.rb' file. Its installs 'Watir 1.4.1' which doesn't contain xpath support. I think you should use either 'install.rb' file for installation or copy the files manually.

I tried the same code & its working on my machine. I was able click the image map. Make sure that the following things are in place:
1. You have latest version of 'watir.rb' file.
2. You have copied 'elements.rb' & 'functions.rb' to [ruby installation directory]/lib/ruby/1.8/rexml

I don't think you need any thing else than this. Just let me know if problem still persists.

Regards,
Angrez
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to