[Wtr-general] How to verify if SPAN is visible

Charley Baker charley.baker at gmail.com
Wed Jan 3 16:48:25 EST 2007


Walking the tree is encapsulated inside the code, it's not advanced. Pull
the code from the page:
http://wiki.openqa.org/pages/viewpage.action?pageId=1119
Put it somewhere in your ruby load path, current directory works.

Save the file to watir_ext.rb in your test directory, then use the following
to try it out.

require 'watir'
require 'watir_ext'
include Watir

ie = IE.new
ie.goto("www.someplace.com")
button = ie.button(:id, 'somebutton')
if button.visible?
  button.click
else
  ie.close
end

-Charley

On 12/21/06, Charley Baker <charley.baker at gmail.com> wrote:
>
> There's a user contribution on the Wiki:
> http://wiki.openqa.org/pages/viewpage.action?pageId=1119    that extends
> element to walk the DOM tree and check for disabled or non-visible elements.
>
>
>
> -Charley
>
> On 12/21/06, Paul Rogers <paul.rogers at shaw.ca> wrote:
> >
> >  didnt some one post a is_visible?  ( or visible?)  method to the list?
> > I think it walked up the dom tree looking to see if parent elements were
> > visible, as the approach here wont work if the element that encloses the
> > span ( if there is one ) is also hidden.
> >
> > Paul
> >
> > ----- Original Message -----
> >  *From:* Željko Filipin <zeljko.filipin at gmail.com>
> > *To:* wtr-general at rubyforge.org
> > *Sent:* Thursday, December 21, 2006 2:45 AM
> > *Subject:* Re: [Wtr-general] How to verify if SPAN is visible
> >
> > For
> >
> > <span style="color: Red; visibility: visible;"
> > id="MainLogin_PasswordRequired">*</span>
> >
> > you can use
> >
> > irb(main):015:0> ie.span(:id, "MainLogin_Password").html
> > => "<SPAN id=MainLogin_PasswordRequired title=\"Password is required.\"
> > style=\"VISIBILITY: visible; COLOR: red\">*</SPAN>"
> > irb(main):016:0> ie.span(:id, "MainLogin_Password").html =~ /visible/
> > => 85
> > irb(main):017:0> ie.span(:id, "MainLogin_Password").html =~ /hidden/
> > => nil
> >
> > It is similar when span is hidden.
> >
> > Is this useful for you? Let me know if it is to cryptic, I will add more
> > detail.
> > --
> > Zeljko Filipin
> > zeljkofilipin.com
> >
> > ------------------------------
> >
> > _______________________________________________
> > Wtr-general mailing list
> > Wtr-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
> >
> > _______________________________________________
> > Wtr-general mailing list
> > Wtr-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070103/8a3040c2/attachment.html 


More information about the Wtr-general mailing list