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

On Jul 8, 2006, at 19:25, [email protected] 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?

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:

http://msdn.microsoft.com/library/default.asp?url=/workshop/
browser/mshtml/reference/reference.asp

In particular the interfaces IWebBrowser2, IHTMLDocument2, and
IHTMLDocument3:

Microsoft Learn: Build skills that open doors in your career
ifaces/iwebbrowser2/iwebbrowser2.asp
Microsoft Learn: Build skills that open doors in your career
document2/document2.asp
Microsoft Learn: Build skills that open doors in your career
document3/document3.asp

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

Xavier N. wrote:

On Jul 8, 2006, at 19:25, [email protected] 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 B.

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

On Jul 8, 2006, at 22:04, Xavier N. wrote:

On Jul 8, 2006, at 19:25, [email protected] 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.

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

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.

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 B.

“You harmonize; then you customize.”

  • Wilson Pickett

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.

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

Hi All,

I really need some help here. I am a recruiter and my client has been
looking for QAs with Ruby -Watir experience. They are located at San
Francisco, CA. Pay is as per market rate. Please mail me back at
[email protected] with resume if interested. I would also
appreciate any referrals. Thanks
Leah

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

On Mon, Oct 17, 2011 at 6:48 AM, bhaskar m. [email protected]
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

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.

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.

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 }