Elements supported by Watir

16 views
Skip to first unread message

Željko Filipin

unread,
Sep 28, 2009, 5:54:56 AM9/28/09
to watir
Do we have a place where all elements (link, image, button...) supported by Watir are listed?

Is this list complete?

http://wiki.openqa.org/display/WTR/Methods+Supported+by+Element

Is there a simple way I could take a look in the code and find which elements Watir supports?

I see we have Element class and I suppose all elements inherit it. I have searched Watir code for `< Element` and found a lot of places where it appears. Is there a central location where all elements are collected?

Željko
--
http://watirpodcast.com/

Bret Pettichord

unread,
Sep 28, 2009, 12:08:43 PM9/28/09
to Watir General
On Sep 28, 4:54 am, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
> Do we have a place where all elements (link, image, button...) supported by
> Watir are listed?
>
> Is this list complete?
>
> http://wiki.openqa.org/display/WTR/Methods+Supported+by+Element

I've been trying to keep it up to date

> Is there a simple way I could take a look in the code and find which
> elements Watir supports?
> I see we have Element class and I suppose all elements inherit it. I have
> searched Watir code for `< Element` and found a lot of places where it
> appears. Is there a central location where all elements are collected?



>> def is_element_subclass? klass
>> while klass = klass.superclass
>> return true if klass == Watir::Element
>> end
>> end

>> ObjectSpace.each_object(Class){|c| puts c if is_element_subclass?(c)}
Watir::HTMLElement
Watir::Link
Watir::Image
Watir::TableCell
Watir::TableRow
Watir::TableBody
Watir::TableBodies
Watir::Table
Watir::CheckBox
Watir::Radio
Watir::RadioCheckCommon
Watir::FileField
Watir::Hidden
Watir::TextField
Watir::Button
Watir::SelectList
Watir::InputElement
Watir::Em
Watir::Strong
Watir::Dd
Watir::Dt
Watir::Dl
Watir::H6
Watir::H5
Watir::H4
Watir::H3
Watir::H2
Watir::H1
Watir::Ul
Watir::Li
Watir::Label
Watir::Area
Watir::Map
Watir::Span
Watir::Div
Watir::P
Watir::Pre
Watir::NonControlElement
Watir::Form


> Željko
> --http://watirpodcast.com/

Željko Filipin

unread,
Sep 29, 2009, 5:26:34 AM9/29/09
to watir-...@googlegroups.com
On Mon, Sep 28, 2009 at 6:08 PM, Bret Pettichord <bpett...@gmail.com> wrote:
> >> def is_element_subclass? klass
> >> while klass = klass.superclass
> >> return true if klass == Watir::Element
> >> end
> >> end
>
> >> ObjectSpace.each_object(Class){|c| puts c if is_element_subclass?(c)}

I executed this code on Mac and Windows and got this error message:

NameError: uninitialized constant Watir::Element
        from (irb):5:in `is_element_subclass?'
        from (irb):9
        from (irb):9:in `each_object'
        from (irb):9

I tried with or without `require "watir"` as the first line.

What am I doing wrong?

Mac:
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0])
commonwatir (1.6.2)
firewatir (1.6.2)
safariwatir (0.3.3)

Windows:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
commonwatir (1.6.2)
firewatir (1.6.2)
watir (1.6.2)

Željko

Željko Filipin

unread,
Sep 30, 2009, 8:06:51 AM9/30/09
to watir-...@googlegroups.com
Frame is missing from this list. I guess it makes sense, but it is still missing.

Željko


On Mon, Sep 28, 2009 at 6:08 PM, Bret Pettichord <bpett...@gmail.com> wrote:

Alister Scott

unread,
Sep 30, 2009, 8:29:04 PM9/30/09
to Watir General
I can't get Bret's code to work either.
I tried all classes and Watir::Element is not included

My Code:

require 'Watir'

def is_element_subclass? klass
while klass = klass.superclass
return true
end
end
ObjectSpace.each_object(Class){|c| puts c if is_element_subclass?(c)}


Cheers,
Alister



On Sep 29, 7:26 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
> On Mon, Sep 28, 2009 at 6:08 PM, Bret Pettichord <bpettich...@gmail.com>

Bret Pettichord

unread,
Oct 5, 2009, 11:01:03 PM10/5/09
to Watir General
require 'watir/ie'

On Sep 29, 4:26 am, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
> On Mon, Sep 28, 2009 at 6:08 PM, Bret Pettichord <bpettich...@gmail.com>

Bret Pettichord

unread,
Oct 5, 2009, 11:03:40 PM10/5/09
to Watir General
Because Frame is not a subclass of Element.

I am curious as to why you find this information helpful. If you want
to know the class of an element, you can always do

> browser.text_field(:id, 'foo').class

Bret

On Sep 30, 7:06 am, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
> Frame is missing from this list. I guess it makes sense, but it is still
> missing.
>
> Željko
>
> On Mon, Sep 28, 2009 at 6:08 PM, Bret Pettichord <bpettich...@gmail.com>

Željko Filipin

unread,
Oct 7, 2009, 7:02:42 PM10/7/09
to watir-...@googlegroups.com
On Tue, Oct 6, 2009 at 5:01 AM, Bret Pettichord <bpett...@gmail.com> wrote:
> require 'watir/ie'

I knew it will be something simple. :)

Thanks, I will try it.

Željko

Željko Filipin

unread,
Oct 7, 2009, 7:03:58 PM10/7/09
to watir-...@googlegroups.com
On Tue, Oct 6, 2009 at 5:03 AM, Bret Pettichord <bpett...@gmail.com> wrote:
> Because Frame is not a subclass of Element.

Makes sense.


> I am curious as to why you find this information helpful.

I just wanted to get a definite list of HTML elements supported by Watir.

Željko

Bret Pettichord

unread,
Oct 8, 2009, 1:12:09 AM10/8/09
to Watir General


On Oct 7, 6:03 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
> On Tue, Oct 6, 2009 at 5:03 AM, Bret Pettichord <bpettich...@gmail.com>
>
> > I am curious as to why you find this information helpful.
>
> I just wanted to get a definite list of HTML elements supported by Watir.

But how do the class names help with this? To me the method names and
the elements supported are user-level information. But the class names
really have to do with how Watir is structured, which is sometimes
ugly inside, but shouldn't matter to most users.

I am worried that this information is being presented in a way that
might lead users to think this is something they should know, and
therefore make Watir look more confusing than it needs to.

Jason

unread,
Oct 18, 2009, 11:46:40 PM10/18/09
to Watir General
Hey Brett,

How is it that you got Watir::Dd, Watir::Dt & Watir::Dl (amongst
others like Watir::Strong) in your list? When I run the same code
these are not returned - wondering if you have custom methods in place
for those, or what I need to do to make sure they are identifiable
elements?

- Jason


On Sep 29, 5:08 am, Bret Pettichord <bpettich...@gmail.com> wrote:
> On Sep 28, 4:54 am, Željko Filipin <zeljko.fili...@wa-research.ch>
> wrote:
>
> > Do we have a place where all elements (link, image, button...) supported by
> > Watir are listed?
>
> > Is this list complete?
>
> >http://wiki.openqa.org/display/WTR/Methods+Supported+by+Element
>
> I've been trying to keep it up to date
>
> > Is there a simple way I could take a look in the code and find which
> > elements Watir supports?
> > I see we have Element class and I suppose all elements inherit it. I have
> > searched Watir code for `< Element` and found a lot of places where it
> > appears. Is there a central location where all elements are collected?
> >> def is_element_subclass?klass
> >> whileklass=klass.superclass
> >> return true ifklass== Watir::Element

Bret Pettichord

unread,
Oct 19, 2009, 12:30:58 AM10/19/09
to watir-...@googlegroups.com
I think I'm running the latest version of Watir: 1.6.5 rc1 or thereabouts.

Bret
--
Bret Pettichord
Lead Developer, Watir, www.watir.com
Blog, www.io.com/~wazmo/blog
Twitter, www.twitter.com/bpettichord

Jason

unread,
Oct 19, 2009, 4:31:35 PM10/19/09
to Watir General
Of course, that would do it. Thought I had upgraded, evidently not - I
was still running 1.6.2.

Cheers,

- Jason

Željko Filipin

unread,
Feb 17, 2010, 8:12:17 AM2/17/10
to watir-...@googlegroups.com, Bret Pettichord

Željko Filipin

unread,
Feb 17, 2010, 8:32:39 AM2/17/10
to watir-...@googlegroups.com, Bret Pettichord
On Tue, Oct 6, 2009 at 4:01 AM, Bret Pettichord <bpett...@gmail.com> wrote:
> require 'watir/ie'

Thanks, I finally got some time to update the code and the output:

http://wiki.openqa.org/display/WTR/HTML+Elements+Supported+by+Watir

Željko

Jarmo Pertman

unread,
Feb 18, 2010, 4:08:33 AM2/18/10
to Watir General
You could even write it without any custom methods
(is_element_subclass?) like this:
require 'watir/ie'
ObjectSpace.each_object(Class) {|c| puts c if c.ancestors.include?
(Watir::Element)}

Although I don't also understand what's the use of the classnames to
regular users...

Jarmo

On Feb 17, 3:32 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
> On Tue, Oct 6, 2009 at 4:01 AM, Bret Pettichord <bpettich...@gmail.com>

Željko Filipin

unread,
Feb 18, 2010, 9:57:18 AM2/18/10
to watir-...@googlegroups.com
On Thu, Feb 18, 2010 at 10:08 AM, Jarmo Pertman <jar...@gmail.com> wrote:
> Although I don't also understand what's the use of the classnames to
> regular users...

Class names just represent html elements that Watir knows about.

Željko
Reply all
Reply to author
Forward
0 new messages