[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to get Response URL value - help requested

Madu Nar

9/29/2006 6:07:00 AM

Hi,
I have a problem here.
I have a ruby code that opens Google, types "book stores" and clicks on
"Search" button.

# Code Snippet Begins here

require 'net/http'
require 'uri'
require 'watir'

term="book stores"

url1 = 'http://www.googl...
ie = Watir::IE.start(url1)
ie.text_field(:name, "q").set(term)
ie.button(:name, "btnG").click

# Code Snippet Ends here

Now I need to obtain the value of the response URL generated by this
search and assign it to a variable.
[ i.e. http://www.google.com/search?hl=en&lr=&q=b...]

How do I read the HTTP Header information for the "location" attribute?
Any help is greatly appreciated.

Thanks,
Madu

--
Posted via http://www.ruby-....

6 Answers

Madu Nar

9/29/2006 10:11:00 PM

0

Any help appreciated... Please let know.

Thanks again,
Madu

Madu Nar wrote:
> Hi,
> I have a problem here.
> I have a ruby code that opens Google, types "book stores" and clicks on
> "Search" button.
>
> # Code Snippet Begins here
>
> require 'net/http'
> require 'uri'
> require 'watir'
>
> term="book stores"
>
> url1 = 'http://www.googl...
> ie = Watir::IE.start(url1)
> ie.text_field(:name, "q").set(term)
> ie.button(:name, "btnG").click
>
> # Code Snippet Ends here
>
> Now I need to obtain the value of the response URL generated by this
> search and assign it to a variable.
> [ i.e. http://www.google.com/search?hl=en&lr=&q=b...]
>
> How do I read the HTTP Header information for the "location" attribute?
> Any help is greatly appreciated.
>
> Thanks,
> Madu


--
Posted via http://www.ruby-....

Andrei Maxim

9/29/2006 11:49:00 PM

0

On Sep 30, 2006, at 1:11 AM, Madu Nar wrote:

>>
>> How do I read the HTTP Header information for the "location"
>> attribute?
>> Any help is greatly appreciated.
>>
>> Thanks,
>> Madu

I have no experience with Watir whatsoever, but the docs show there's
a url() method.

http://wtr.rubyforge.org/rdoc/classes/Watir/IE.ht...

Did you check it out?

Andrei

Madu Nar

9/30/2006 10:35:00 PM

0

Andrei Maxim wrote:
> On Sep 30, 2006, at 1:11 AM, Madu Nar wrote:
>
>>>
>>> How do I read the HTTP Header information for the "location"
>>> attribute?
>>> Any help is greatly appreciated.
>>>
>>> Thanks,
>>> Madu
>
> I have no experience with Watir whatsoever, but the docs show there's
> a url() method.
>
> http://wtr.rubyforge.org/rdoc/classes/Watir/IE.ht...
>
> Did you check it out?
>
> Andrei

Thanks Andrei,
Did try the url() function from Watir but that did not work and gave me
the following exceptions...
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1405:in `method_missing'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1405:in `wait'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1404:in `upto'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1404:in `wait'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2014:in `click'
nethttp_1.rb:16
W, [30-Sep-2006 15:33:33#2288] WARN -- : frame error in waitdocument
OLE error code:80070005 in <Unknown>
Access is denied.


HRESULT error code:0x80020009
Exception occurred.
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1405:in `method_missing'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1405:in `wait'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1404:in `upto'
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1404:in `wait'
nethttp_1.rb:22

I am still trying but not successful yet.

Thanks,
Madu

--
Posted via http://www.ruby-....

bpettichord

10/11/2006 12:46:00 AM

0

> How do I read the HTTP Header information for the "location" attribute?
> Any help is greatly appreciated.

This information is not available in Watir. You could use a http proxy
to get this information.

Bret

(Alex Furman)

10/12/2006 7:47:00 PM

0

You can try SWExplorerAutomation SWEA (http://webunitt...).

Example:

require 'rubyclr'
RubyClr::reference 'System'
RubyClr::reference 'SWExplorerAutomationClient'
include SWExplorerAutomation::Client
include SWExplorerAutomation::Client::Controls
include SWExplorerAutomation::Client::DialogControls
explorerManager = ExplorerManager.new
explorerManager.Connect(-1)
explorerManager.LoadProject('google.htp')
explorerManager.Navigate('http://www.google...)
scene = explorerManager['Scene_0']
scene.WaitForActive(30000)
scene["q"].Value = 'c#'
scene['btnG'].Click()
scene = explorerManager['Scene_1']
scene.WaitForActive(30000)
puts scene.RuntimeSceneInfo.Url
explorerManager.DisconnectAndClose()

Result:
D:\Temp>test.rb
http://www.google.com/search?hl=en&q=c%23&btnG=Goo...

RubyCLR. Complete Installation Guide:
http://gaech.blogspot.com/2006/10/rubyclr-complete-installation-...


Bret Pettichord wrote:
> > How do I read the HTTP Header information for the "location" attribute?
> > Any help is greatly appreciated.
>
> This information is not available in Watir. You could use a http proxy
> to get this information.
>
> Bret

(Alex Furman)

10/12/2006 7:48:00 PM

0

You can try SWExplorerAutomation SWEA (http://webunitt...).

Example:

require 'rubyclr'
RubyClr::reference 'System'
RubyClr::reference 'SWExplorerAutomationClient'
include SWExplorerAutomation::Client
include SWExplorerAutomation::Client::Controls
include SWExplorerAutomation::Client::DialogControls
explorerManager = ExplorerManager.new
explorerManager.Connect(-1)
explorerManager.LoadProject('google.htp')
explorerManager.Navigate('http://www.google...)
scene = explorerManager['Scene_0']
scene.WaitForActive(30000)
scene["q"].Value = 'c#'
scene['btnG'].Click()
scene = explorerManager['Scene_1']
scene.WaitForActive(30000)
puts scene.RuntimeSceneInfo.Url
explorerManager.DisconnectAndClose()

Result:
D:\Temp>test.rb
http://www.google.com/search?hl=en&q=c%23&btnG=Goo...

RubyCLR. Complete Installation Guide:
http://gaech.blogspot.com/2006/10/rubyclr-complete-installation-...


Bret Pettichord wrote:
> > How do I read the HTTP Header information for the "location" attribute?
> > Any help is greatly appreciated.
>
> This information is not available in Watir. You could use a http proxy
> to get this information.
>
> Bret