WAtir usage

Hi
I found Watir and am excited to use it. I cannot find much examples in
terms of data scraping. I have gotne to a point wherei can use it to
submit form details.
I need to scrape data from the tables etc. How do i do it.
For eg my if ie is my browser object, how do i get the tables in the
page and extract data from 3 table in the page into a array?

Pl help.

Seede

Watir is a wrapper around MSIE. In my limited experience crawling with Watir, besides reading its documentation I think it's good to study the underlying API, available here:

   Technical documentation | Microsoft Learn

In particular the interfaces IWebBrowser2, IHTMLDocument2, and IHTMLDocument3:

   Microsoft Learn: Build skills that open doors in your career
   Microsoft Learn: Build skills that open doors in your career
   Microsoft Learn: Build skills that open doors in your career

There you see what can be done grabbing the ie attribute of the Watir::IE object, in case the wrapping interface does not address some particular need. Additionally, I have found reading watir.rb very instructive, you have a better knowledge of what you are doing and may give context and idioms.

-- fxn

···

On Jul 8, 2006, at 19:25, junkone@rogers.com wrote:

Hi
I found Watir and am excited to use it. I cannot find much examples in
terms of data scraping. I have gotne to a point wherei can use it to
submit form details.
I need to scrape data from the tables etc. How do i do it.
For eg my if ie is my browser object, how do i get the tables in the
page and extract data from 3 table in the page into a array?

Hi this is Bhaskar Munnuri.I have a doubt the the watir is an pure
object oriented programming language or not
if yes how.why because it does not support multiple inheritance directly
so how the oops concept can satisfies

···

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

Hi,

Does anyone knows how can I access or click on the data inside the "var
createMenuItems" in the attachment. This are menu dropdowns created when
I click on a particular tag(not included in the attachment).
Any help is greatly appreciated.
Thanks.

Attachments:
http://www.ruby-forum.com/attachment/8216/html_page.txt

···

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

I'm not sure about Watir, but in Watir-Webdriver you extract script
content like this:

driver.scripts[index].html

or

driver.scripts.each { |s| puts s.html }

···

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

Xavier Noria wrote:

There you see what can be done grabbing the ie attribute of the Watir::IE object, in case the wrapping interface does not address some particular need. Additionally, I have found reading watir.rb very instructive, you have a better knowledge of what you are doing and may give context and idioms.

About a year or so ago I poked around trying to get HTML from IE in Watir. The problem (and maybe this has changed) was that the IE object did not have a way to get the literal text currently in the browser; there was no COM 'view|source', so to speak.

What it exposed was access to IE's internal node tree, which is *not* what is in the browser. IE adds all sorts of things (for DHTML and such, as well as, I think, the various implied attributes defined in the HTML DTD. Something akin to the post-schema infoset, I think.) so it is useless for verifying server output. Still, it is handy in other ways; you can locate, say, table elements and td content and so on.

I wrote a method that did a recursive walk down the internal IE tree and created an XML string from it. Contact me off-list if you would like me to send it to you. It's old and may not work with the current Watir, but might give you some ideas.

james DOT britt AT gmail DOT com

···

On Jul 8, 2006, at 19:25, junkone@rogers.com wrote:

--
James Britt

http://www.ruby-doc.org - Ruby Help & Documentation
Ruby Code & Style - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://refreshingcities.org - Design, technology, usability

By the way, regarding the question about tables you can do this:

   table = ie.table(:index, 3)

That index is 1-based and returns an object of type Watir::Table or nil. As per the definition of order between tables, it is delegated to IE this way:

   @ieController.document.getElementsByTagName("TABLE")

-- fxn

···

On Jul 8, 2006, at 22:04, Xavier Noria wrote:

On Jul 8, 2006, at 19:25, junkone@rogers.com wrote:

Hi
I found Watir and am excited to use it. I cannot find much examples in
terms of data scraping. I have gotne to a point wherei can use it to
submit form details.
I need to scrape data from the tables etc. How do i do it.
For eg my if ie is my browser object, how do i get the tables in the
page and extract data from 3 table in the page into a array?

There you see what can be done grabbing the ie attribute of the Watir::IE object, in case the wrapping interface does not address some particular need. Additionally, I have found reading watir.rb very instructive, you have a better knowledge of what you are doing and may give context and idioms.

Watir is not a language at all; it is a library written in Ruby. Ruby
is generally considered a pure object-oriented language, since every
value is a full-fledged object (i.e. it responds to methods, etc.) --
unless in languages like C++ or Java where you have types like int and
double which are not objects.

Multiple inheritance is actually pretty rare in object-oriented
languages; language designers seem to generally consider multiple
inheritance to cause a lot of difficulties in implementation.

Many languages have a construct similar (but not identical) to a
class, which allows for some of the things you might use multiple base
classes for in a language like C++. For example, Java and C# have
interfaces, and Objective-C has protocols. Ruby has modules, also
known as mixins. Still, inheritance in general isn't emphasized in
Ruby.

···

On Mon, Oct 17, 2011 at 6:48 AM, bhaskar m. <bhaskar.munnuri@gmail.com> wrote:

Hi this is Bhaskar Munnuri.I have a doubt the the watir is an pure
object oriented programming language or not
if yes how.why because it does not support multiple inheritance directly
so how the oops concept can satisfies

You should be able to do something like

Browser.html()

To grab the original source.

There is also a Watir specific newsgroup somewhere around rubyforge.

···

-----Original Message-----
From: James Britt [mailto:james.britt@gmail.com]
Sent: Saturday, July 08, 2006 1:33 PM
To: ruby-talk ML
Subject: Re: WAtir usage

Xavier Noria wrote:

On Jul 8, 2006, at 19:25, junkone@rogers.com wrote:

There you see what can be done grabbing the ie attribute of the
Watir::IE object, in case the wrapping interface does not address some
particular need. Additionally, I have found reading watir.rb very
instructive, you have a better knowledge of what you are doing and may
give context and idioms.

About a year or so ago I poked around trying to get HTML from IE in
Watir. The problem (and maybe this has changed) was that the IE object
did not have a way to get the literal text currently in the browser;
there was no COM 'view|source', so to speak.

What it exposed was access to IE's internal node tree, which is *not*
what is in the browser. IE adds all sorts of things (for DHTML and such,
as well as, I think, the various implied attributes defined in the HTML
DTD. Something akin to the post-schema infoset, I think.) so it is
useless for verifying server output. Still, it is handy in other ways;
you can locate, say, table elements and td content and so on.

I wrote a method that did a recursive walk down the internal IE tree and
created an XML string from it. Contact me off-list if you would like me
to send it to you. It's old and may not work with the current Watir,
but might give you some ideas.

james DOT britt AT gmail DOT com

--
James Britt

http://www.ruby-doc.org - Ruby Help & Documentation
Ruby Code & Style - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://refreshingcities.org - Design, technology, usability

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/383 - Release Date: 7/7/2006

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/383 - Release Date: 7/7/2006

Alan Ark wrote:

You should be able to do something like

Browser.html()

To grab the original source.

Well, that *would* save a good deal of trouble.

Thanks!

···

--
James Britt

"You harmonize; then you customize."
  - Wilson Pickett

What do you mean? Watir::IE#html gives a dump of the internal MSIE representation, tags are in uppercase, quotes are removed from some attributes, etc. What James mentioned a few messages above.

-- fxn

···

On Jul 10, 2006, at 23:13, Alan Ark wrote:

You should be able to do something like

Browser.html()

To grab the original source.