Re: [wtr-general] How to get the status of http

2011-05-22 Thread Amit Bobade
Dear Qiannan,

Here is the answer of you question. Use following code. This is working
code. I used this in my scripts.

require 'net/http'
require 'uri'

def page_status url
  url = URI.parse(url)

  http = Net::HTTP.new(url.host, url.port)

  http.start do
http.request_get(url.path.empty? ? "/" : url.path) do |res|
  return {:name => res.class, :code => res.code}
end
  end
end

status = page_status("http://www.yourURL.com";)

# Printing response class and status.

puts res_class=status[:name]
puts stat=status[:code]



On Sat, May 21, 2011 at 9:25 PM, Qiannan Zhang  wrote:

> Hi, all
> I need help, i do not know how to get the status of http, is there anyone
> know how to do?
> thanks
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
>



-- 
Thanks and Regards,
Amit

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Re: Where to put user defined class to include it in various scripts

2011-05-22 Thread Amit Bobade
Thanks a ton, Joedio. :)

On Sat, May 21, 2011 at 6:15 PM, joedio  wrote:

> Amit,
>
> These are indeed a Ruby questions NOT a Watir questions.
> I appreciate your candor in noting that with your question.
>
> The answers to your questions are:
> 1. Where to save this class so that I will be able to include it in my
> scripts?
> A: You can save it anywhere you like in the file system
>
> 2. Can I include this class using 'require' ?
> A: Yes
>
> I STRONGLY recomend that you now refer to
> the "require" and "include" methods in Ruby RDoc
>   http://ruby-doc.org/core/
>
> It will explain the use of those (and many many more)
> methods available with Ruby.
>
> Also if you have Ruby 1.8.7 installed take the time to read the
> documents which are under the \doc directory under your Ruby install
> path.
> Reading them will save you a lifetime of grief and confusion.
>
> You can also find this on-line at:
> http://www.ruby-doc.org/docs/ProgrammingRuby/
>
>
> Joe
>
> On May 21, 4:24 am, Amit Bobade  wrote:
> > *Dear All:*
> >
> > This is more like a Ruby Question. Could anybody help me?
> >
> > I have written a class and now I require it for some scripts. So instead
> of
> > copying this class in every script  I have to include this class in my
> > scripts.
> > Therefore, please tell me
> >
> > 1. Where to save this class so that I will be able to include it in my
> > scripts?
> > 2. Can I include this class using 'require' ?
> >
> > --
> > Thanks and Regards,
> > Amit
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
>



-- 
Thanks and Regards,
Amit

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: How to utilize resulting array from browser.links.find_all { |x| x stuff } command

2011-05-22 Thread Abe Heward
Good to know. Thanks!

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Watir simple field recorder

2011-05-22 Thread Abe Heward
What's the thinking behind going with the structure...

def field_name
  browser.thing(:how, "what")
end

...versus simply:

field_name = browser.thing(:how, "what")

?

Are there advantages/disadvantages with each?

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com