require 'uri'
my_url=URI::parse("http://www.blah.com/uk/home.asp?variable";)
puts my_url.scheme
puts my_url.host
puts my_url.path
puts my_url.query

You can put together the pieces you need:

"#{my_url.scheme}://#{my_url.host}#{my_url.path}"

So your code becomes:

require 'watir'
require 'uri'
test_site="http://www.blah.com/uk/home.asp?src=ash";
ie = Watir::IE.new
ie.speed = :fast

ie.goto test_site

url=URI::parse(ie.url)

if "#{url.scheme}://#{url.host}#{url.path}" == "http://www.blah.com/uk/
home.asp"
  puts "ok"
else
  puts "bugger!"
end

Whether this is a good idea depends on how advanced your scripts
eventually get.

Jared
http://www.quinert.com/blog/


On May 1, 9:30 pm, ash <[email protected]> wrote:
> Having searched this group, plus the wiki, plus the mail archives I am
> still a little confused as to the syntax format for stripping text
> from a url.  Apologies if there is a thread covering this already but
> I am now getting frustrated with this as it seems such a simple task
> but I can't get my head round it.
>
> I have a check in a test to ensure that the url reached is correct but
> there is a variable at the end of the url that I don't need.  How do I
> get rid of this?
>
> My url is of the formathttp://www.blah.com/uk/home.asp?variable
>
> So far I have discovered that the following will possibly help;
> new_url = ie.url[/(.*)\//] although this strips everything after
> "uk/".  I just need to strip out "?variable".
>
> My question is really; What does this mean? [/(.*)\//]
>
> Cheers...Ash
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to