How do make the element_by_xpath work?

96 views
Skip to first unread message

bugs apple

unread,
Oct 8, 2008, 11:15:40 PM10/8/08
to watir-...@googlegroups.com
hi, all
 
In my html file, there are some script like below,
<input type = "text" id="id1", name="wiston"  > <br>
<input type = "text" id="id2", name="wiston"  > <br>
<input type = "text" id="id3", name="wiston"  > <br>
 
 
develop the watir code like this,
 
ie=Watir::IE.attach(:title, /title/)
ie.element_by_xpath("//input[@name='wiston']/").set("hello")
 
it throws C:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/watir/RubyApplication2/lib/main.rb:90:in `method_missing': unknown property or method `set' (WIN32OLERuntimeError)
    HRESULT error code:0x80020006
Anybody can tell me How do make the element_by_xpath work?
 
 

Angrez Singh

unread,
Oct 10, 2008, 2:45:13 AM10/10/08
to watir-...@googlegroups.com
Try this:
ie.element_by_xpath("//input[@name='wiston']").set("hello")

basically i removed the forward slash at the end of Xpath query.

- Angrez

wesley chen

unread,
Oct 10, 2008, 3:38:11 AM10/10/08
to watir-...@googlegroups.com
it won't work, because
 ie.element_by_xpath("//input[@name='wiston']").class ='win32ole'
for win32ole object, there is no method of 'set'

bugs apple

unread,
Oct 10, 2008, 5:19:30 AM10/10/08
to watir-...@googlegroups.com
Yes, wesley is right
 
How do make the ie.element_by_xpath that return OLE object work well?
 
Or tell me how to transfer the ole object to the normal object so that let the
set-method work?

2008/10/10 wesley chen <cjq...@gmail.com>

juuser

unread,
Oct 10, 2008, 6:28:00 AM10/10/08
to Watir General
why not use ie.text_field(:id, "id1").value = "hello" ?
Reply all
Reply to author
Forward
0 new messages