Doink, that's what happens when you have tunnel vision on one thing, try to multitask and don't pay attention. Jeff and Dave are right, never mind my post unless you also want to get the http headers someday. :)

On 8/19/06, Jeff Wood <[EMAIL PROTECTED]> wrote:
Since the meta tags are inside the HTML document itself, you can get to
them ... you just have to use ruby stuff to do it... ( a lot of people go
thinking that watir is something self-contained ... it's *JUST* a ruby
library that hooks to IE, not downplaying it, but ... you have an entire
programming language available to you ) and getting this information is
cake.

So, ... try the following:

--BEGIN--
length = ie.document.getElementsByTagName( "meta" ).length

metas = {}
http_equivs = {}

length.times do |i|

   body = ie.document.getElementsByTagName( "meta" ).item(i).outerHTML
   puts body

   # I leave it to you to come up with good regular expressions for parsing
things out.

   # these work but are overly greedy.
   matches = body.scan( /name="(.+)"/ )
   name = matches[1] || ""
   matches = body.scan( /content="(.+)"/ )
   content = matches[1] || ""
   matches = body.scan( /http-equiv="{0,1}(.+)"{0,1}/ )
   http_equiv = matches[1] || ""

   http_equivs[http_equiv] = content if http_equiv != ""
   metas[name] = content if name != ""

end

--END--

Hope that helps.

jd

On Sat, 19 Aug 2006 10:14:27 -0700, Charley Baker
<[EMAIL PROTECTED]> wrote:

> Watir deals with the html of the page, not the http headers. I'm not sure
> what the hard way is that you're dealing with currently, but you can
> access
> most of this information through ruby's net libraries:
>
> http://www.rubycentral.com/book/lib_network.html
>
> Take a look at the section: class Net::HTTP
> There are some pretty simple examples which should get you what you want,
> then it's a matter of pulling out whatever headers you're interested in
> from
> the returned hash and asserting on them.
>
> -Charley
>
> On 8/16/06, Alien Ruby <[EMAIL PROTECTED]> wrote:
>>
>> Let me make clearer...
>>
>> for example,
>>
>> ie.title of this page will out put "OpenQA Forums: Watir General"
>>
>> but, I want something that can spits out the meta tag. like
>>
>> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
>>
>> or just the name and content? and what if they have multiple meta tags?
>>
>> I've been doing this a hard way. I assume this can be done in a very
>> easy
>> way, will it? maybe something like ie.meta...... it.html.meta....
>>
>> please any suggestion will be accepted.
>>
>> thank you soo much.
>> ---------------------------------------------------------------------
>> Posted via Jive Forums
>> http://forums.openqa.org/thread.jspa?threadID=3625&messageID=10048#10048
>> _______________________________________________
>> Wtr-general mailing list
>> Wtr-general@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/wtr-general
>>


_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to