If it's all too ugly to bear lookin at it, wrap it in a Ruby method or class. For example, you might add a method visible? to Element. In that method, you could ascend the DOM tree, checking first the node and then each parentNode in turn to see if it is visible (climbing the tree in the reverse the cascade of inheritance).
John
On 10/17/05, amol deshpande <[EMAIL PROTECTED]> wrote:
Hi John,
i was getting on samelines with the OLEObject
but was not getting the.invoke("Display").
Thanks a lot for your suggestions.I will try this now.
Amol
--- John Lloyd-Jones < [EMAIL PROTECTED]>
wrote:
> Anol
>
> OK, not sure if you'll like it, but here's the deal:
>
> Watir will let you do this:
>
> name = $ie.text_field(:name,
> "customer.professionalName.first")
> o = name.getOLEObject()
> display = o.invoke ("style").invoke ("display")
> puts "customer.professionalName.first has display :
> '#{display.to_s}'"
>
> The above get's the OLE object (that mathod name may
> change in the future).
> You can invoke the attribute to get the value. Not
> pretty, but it works.
> ALAS, this does not actually show if the control is
> visible. In my case, the
> display/hide logic works on a surrounding DIV
> element, so I would have:
>
> div = $ie.div(:id, "profname")
> o = div.getOLEObject()
> display = o.invoke ("style").invoke ("display")
> puts "div profname has display : '#{display.to_s}'"
>
> div = $ie.div(:id, "nonprofname")
> o = div.getOLEObject()
> display = o.invoke ("style").invoke ("display")
> puts "div nonprofname has display :
> '#{display.to_s}'"
>
> and get:
> div profname has display : 'block'
> div nonprofname has display : 'none'
> in reply.
>
> In other words, you must check the property on the
> element that is scripted
> to display or no. And you would need to know if the
> element is hidden as
> display: none or visibility: hidden. I guess this is
> not the nice simple
> solution you wanted, but this code does actually get
> the values. You decide
> if it's worth the bother.
>
> John
>
>
> On 10/17/05, amol deshpande <[EMAIL PROTECTED]>
> wrote:
> >
> > Thanks J and vishal for trying.
> > Has any body else encountered this problem before?
> > AD
> >
> > --- Jeff Wood <[EMAIL PROTECTED]> wrote:
> >
> > > I know that somewhere deep down through all of
> the
> > > OLE crud ... the
> > > visibility of a control SHOULD be discernable.
> > > Just haven't found it.
> > > j.
> > >
> > > On 10/17/05, Vishal Chavan
> > > <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi Amol,
> > > >
> > > > I am a newbie as far as Watir is concerned,
> but
> > > while struggling with a
> > > > problem discovered that you can definately get
> the
> > > attributes for a control.
> > > > Here is the code..Hope that what ur looking
> for...
> > > >
> > > > require 'watir'
> > > >
> > > > require 'test/unit'
> > > >
> > > > ie =
> > >
> >
>
Watir::IE.start("http://wtr.rubyforge.org/watir_user_guide.html")
> > > >
> > > >
> > > > var = ie.checkbox(:name, "checkme")
> > > >
> > > > puts var
> > > >
> > > > var = ie.radio(:name, "clickme")
> > > >
> > > > puts var
> > > >
> > > > #--------You get following output..
> > > >
> > > > #type: checkbox
> > > > id:
> > > > name: checkme
> > > > value: 1
> > > > disabled: false
> > > >
> > > >
> > > > type: radio
> > > > id: 1
> > > > name: clickme
> > > > value: on
> > > > disabled: false
> > > >
> > > > Though this does not prove if the control is
> > > visible or not...Also there
> > > > need to be a parser to parse the data in this
> > > case... If u learn some better
> > > > way to do this, please let me know.
> > > >
> > > > Thanks,
> > > >
> > > > Vishal
> > > >
> > > >
> > > > --- amol deshpande <[EMAIL PROTECTED]> wrote:
> > > >
> > > > From: amol deshpande < [EMAIL PROTECTED]>
> > > > Date: Mon, 17 Oct 2005 10:29:05 -0700 (PDT)
> > > > To: [email protected]
> > > > Subject: [Wtr-general] How to check visibility
> of
> > > a control?
> > > >
> > > > Hi All,
> > > > I wanted to check the visibility of a control
> on a
> > > > page.
> > > > I was wondering if there is any methd such as
> > > > getAttribute()
> > > > When i tried this ..
> > > > ie.show_attributes
> > > > or
> > > > control_name = ie.control(:id,"abc")
> > > > ie.getAttribute(control_name,"style.display")
> > > > i get a error message No Such Method.
> > > > Does anybody have any Idea of getting around
> this.
> > > > Thanks
> > > > AD
> > > >
> > > > No Body Has ever Collided With The Sky...So
> Sky Is
> > > The Limit!
> > > >
> > > >
> > > >
> > > > __________________________________
> > > > Yahoo! Music Unlimited
> > > > Access over 1 million songs. Try it free.
> > > > http://music.yahoo.com/unlimited/
> > > >
> _______________________________________________
> > > > Wtr-general mailing list
> > > > [email protected]
> > > >
> http://rubyforge.org/mailman/listinfo/wtr-general
> > > >
> > > >
> > > >
> > > > ------------------------------
> > > > Join SQAtester.com Community --->
> > > >
> http://www.sqatester.com/testersarea/joinus.htm
> > > >
> > > >
> _______________________________________________
> > > > Wtr-general mailing list
> > > > [email protected]
> > > >
> http://rubyforge.org/mailman/listinfo/wtr-general
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > "http://ruby-lang.org -- do you ruby?"
> > >
> > > Jeff Wood
> > > >
> _______________________________________________
> > > Wtr-general mailing list
> > > [email protected]
> > >
> http://rubyforge.org/mailman/listinfo/wtr-general
> > >
> >
> >
> > No Body Has ever Collided With The Sky...So Sky Is
> The Limit!
>
=== message truncated ===>
_______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
>
No Body Has ever Collided With The Sky...So Sky Is The Limit!
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
_______________________________________________
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
