Actually, no. There is no code in Watir for accessing elements by class. (P
is a subclass of Span/Div).
However, P and Span and Div all allow you to access the class of an element
using the incorrectly named 'style' method. (I'll fix this shortly.)
Bret
irb(main):007:0> ie =
Watir::IE.start('d:\workspace\watir\unittests\html\div.htm
l')
=> #<Watir::IE:0x2ac9428 @ie=#<WIN32OLE:0x2ac9230>, @defaultSleepTime=0.1,
@page
HasReloaded=false,
@error_checkers=[#<Proc:[EMAIL PROTECTED]:/ruby/lib/ruby/site_ruby
/1.8/watir.rb:1213>], @logger=#<Watir::DefaultLogger:0x2ac9110
@logdev=#<Logger:
:LogDevice:0x2ac90b0 @shift_size=nil, @shift_age=nil, @filename=nil,
@dev=#<IO:0
x278e7d0>>, @level=2, @datetime_format="%d-%b-%Y %H:%M:%S", @progname=nil>,
@typ
ingspeed=0.08, @activeObjectHighLightColor="yellow", @down_load_time=0.07,
@enab
le_spinner=false,
@url_list=["file://D:\\workspace\\watir\\unittests\\html\\div.
html"], @form=nil>
irb(main):008:0> ie.p(:id, 'number1').text
=> "This text is in a p with an id of number1 and title of P_tag_1"
irb(main):009:0> ie.p(:id, 'number1').style
=> "redText"
irb(main):010:0> ie.p(:class, 'redText').text
Watir::Exception::MissingWayOfFindingObjectException: unknown way of
finding a P
( {what} )
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1098:in
`getNonControlObjec
t'
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2430:in `initialize'
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2508:in `initialize'
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:661:in `new'
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:661:in `p'
from (irb):10
from :0
irb(main):011:0>
At 12:10 PM 8/3/2005, Jonathan Kohl wrote:
I think so, yes.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:wtr-general-
> [EMAIL PROTECTED] On Behalf Of Paul Rogers
> Sent: August 3, 2005 10:50 AM
> To: [email protected]
> Subject: Re: [Wtr-general] Question: Javascript/CSS onClick?
>
> isnt this already supported for spans and divs?
>
> Paul
>
> ----- Original Message -----
> From: [EMAIL PROTECTED]
> Date: Wednesday, August 3, 2005 10:30 am
> Subject: Re: [Wtr-general] Question: Javascript/CSS onClick?
>
> >
> > > >It would be better if you can get an id added to that cell
> > >
> > > Or if we supported ie.cell(:class, 'loginOnOut').click.
> > >
> > > I recently ran into another case where it would have been
> > convenient to use
> > > the class name to specify an element. Any other interest in this
> > idea?I think it's a great idea. I couldn't deal with CSS with
> > other tools - this is a
> > big strength of Watir.
> >
> > -Jonathan
> >
> > _______________________________________________
> > Wtr-general mailing list
> > [email protected]
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
>
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_____________________
Bret Pettichord
www.pettichord.com
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general