# How to get Response URL value - help requested

**URL:** <https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451>\
**Category:** ruby-talk\
**Created:** [29 September 2006 06:07 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451 "2006-09-29T06:07:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madu\_Nar](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Madu\_Nar](https://rubytalk.org/u/Madu_Nar)\
**Post date:** [29 September 2006 06:07 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451/1 "2006-09-29T06:07:02Z")

</div>

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.google.com](http://www.google.com)'  
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=book+stores](http://www.google.com/search?hl=en&lr=&q=book+stores)]

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

Thanks,  
Madu

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Madu\_Nar](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Madu\_Nar](https://rubytalk.org/u/Madu_Nar)\
**Post date:** [29 September 2006 22:11 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451/2 "2006-09-29T22:11:17Z")

</div>

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.google.com](http://www.google.com)'  
> > 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. [book stores\ - Google Search](http://www.google.com/search?hl=en&lr=&q=book+stores%5C)]
> > 
> > How do I read the HTTP Header information for the "location" attribute?  
> > Any help is greatly appreciated.
> > 
> > Thanks,  
> > Madu
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Bret\_Pettichord](https://rubytalk.org/u/Bret_Pettichord)\
**Post date:** [11 October 2006 00:50 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451/3 "2006-10-11T00:50:06Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![Andrei\_Maxim](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@Andrei\_Maxim](https://rubytalk.org/u/Andrei_Maxim)\
**Post date:** [29 September 2006 23:48 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451/4 "2006-09-29T23:48:46Z")

</div>

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

[http://wtr.rubyforge.org/rdoc/classes/Watir/IE.html#M000293](http://wtr.rubyforge.org/rdoc/classes/Watir/IE.html#M000293)

Did you check it out?

Andrei

> **···**
>
> 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

---

<div class="post-metadata">

**Author:** ![alex\_f\_il](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alex\_f\_il](https://rubytalk.org/u/alex_f_il)\
**Post date:** [12 October 2006 19:50 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451/5 "2006-10-12T19:50:19Z")

</div>

You can try SWExplorerAutomation SWEA ([http://webunittesting.com](http://webunittesting.com)).

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.com/&#39;\](http://www.google.com/&#39;%5C))  
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=Google+Search](http://www.google.com/search?hl=en&q=c%23&btnG=Google+Search)

RubyCLR. Complete Installation Guide:  
[http://gaech.blogspot.com/2006/10/rubyclr-complete-installation-guide.html](http://gaech.blogspot.com/2006/10/rubyclr-complete-installation-guide.html)

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

---

<div class="post-metadata">

**Author:** ![alex\_f\_il](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alex\_f\_il](https://rubytalk.org/u/alex_f_il)\
**Post date:** [12 October 2006 19:50 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451/6 "2006-10-12T19:50:20Z")

</div>

You can try SWExplorerAutomation SWEA ([http://webunittesting.com](http://webunittesting.com)).

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.com/&#39;\](http://www.google.com/&#39;%5C))  
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=Google+Search](http://www.google.com/search?hl=en&q=c%23&btnG=Google+Search)

RubyCLR. Complete Installation Guide:  
[http://gaech.blogspot.com/2006/10/rubyclr-complete-installation-guide.html](http://gaech.blogspot.com/2006/10/rubyclr-complete-installation-guide.html)

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

---

<div class="post-metadata">

**Author:** ![Madu\_Nar](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Madu\_Nar](https://rubytalk.org/u/Madu_Nar)\
**Post date:** [30 September 2006 22:34 UTC](https://rubytalk.org/t/how-to-get-response-url-value-help-requested/31451/7 "2006-09-30T22:34:58Z")

</div>

Andrei Maxim 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.html#M000293](http://wtr.rubyforge.org/rdoc/classes/Watir/IE.html#M000293)
> 
> 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  
&nbsp;&nbsp;&nbsp;&nbsp;OLE error code:80070005 in \<Unknown\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Access is denied.

&nbsp;&nbsp;&nbsp;&nbsp;HRESULT error code:0x80020009  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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

> **···**
>
> > On Sep 30, 2006, at 1:11 AM, Madu Nar wrote:
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
