broken
September 1, 2009, 12:51pm
1
Hi there folks!
I am trying to automate a browser task with win32ole. The browser is
Internet Explorer.
I used this tutorial:
So the code for clicking a normal button goes like
require ‘win32ole’
ie = WIN32OLE.new(‘InternetExplorer.Application’)
ie.Document.All.btnG.click
where ‘bntG’ is the name of the button.
The HTML for my radio button looks like this:
The problem is the name=“type”, I think.
When I do this ‘ie.Document.All.type’ ooops, didn’t want to know it’s
type…
Any way around this?
I’d rather not use fat libraries like watir.
broken
September 1, 2009, 2:40pm
2
Df Gh wrote:
Hi there folks!
I am trying to automate a browser task with win32ole. The browser is
Internet Explorer.
I used this tutorial:
Ruby on Windows: Automating Internet Explorer with Ruby: Without Watir
So the code for clicking a normal button goes like
require ‘win32ole’
ie = WIN32OLE.new(‘InternetExplorer.Application’)
ie.Document.All.btnG.click
where ‘bntG’ is the name of the button.
The HTML for my radio button looks like this:
The problem is the name=“type”, I think.
When I do this ‘ie.Document.All.type’ ooops, didn’t want to know it’s
type…
Any way around this?
I’d rather not use fat libraries like watir.
A group of radio buttons will probably share the same control name, so
you can’t reference an individual button by name.
But you can iterate over the input controls and check the one with the
desired value:
ie.Document.All.Tags(‘input’).each do |control|
if control.value == ‘reference’
control.checked = true
end
end
Let me know if that works for you.
David
broken
September 1, 2009, 2:57pm
3
David M. wrote:
A group of radio buttons will probably share the same control name, so
you can’t reference an individual button by name.
But you can iterate over the input controls and check the one with the
desired value:
ie.Document.All.Tags(‘input’).each do |control|
if control.value == ‘reference’
control.checked = true
end
end
Let me know if that works for you.
David
http://rubyonwindows.blogspot.com
Thanks David, it works. I found out you can do it like this too:
ie.Document.All.Type(3).Click
Writing Type capitalized does the trick. And (3) stands for the 4th
radio button element.
Now I have another minor problem.
When the form is filled, I submit it via
ie.Document.Forms(0).Submit
But before I can get the resulting links
links = ie.Document.All.Tags(‘a’)
I have to do
sleep(1)
ie.Refresh
after the submit, or else I get the old page.
Any other way to get the updated results?
broken
September 1, 2009, 2:58pm
4
Hi,
2009/9/1 Df Gh [email protected] :
ie = WIN32OLE.new(‘InternetExplorer.Application’)
Any way around this?
I’d rather not use fat libraries like watir.
You can use getElementsByName like this:
ie.Document.getElementsByName(‘type’).item(0).click
Regards,
Park H.