I had this same problem, and the problem is deeper than it seems. I had 
an element and I had to determine if it was visible or not, but 
sometimes the element was NOT visible, even when it didn't have 
"display: none" or "visibility: hidden". Turns out a parent DIV a few 
levels up *was* hidden, and all it's children were thus hidden.

I've added a #visible? method to the modal_dialog branch which iterates 
up to the top of the DOM tree checking to make sure every parent element 
is visible. Note that this is a relatively SLOW call because the only 
way to ensure an element is visible is to make sure every parent is visible.

If you place the following code in a file and require it you should be 
able to do an "element.visible?" call.

class Element
# If any parent element isn't visible then we cannot write to the
# element. The only realiable way to determine this is to iterate
# up the DOM element tree checking every element to make sure it's
# visible.
def visible?
# Now iterate up the DOM element tree and return false if any
# parent element isn't visible or is disabled.
object = document
while object
begin
if object.style.invoke('visibility') =~ /^hidden$/i
return false
end
if object.style.invoke('display') =~ /^none$/i
return false
end
if object.invoke('isDisabled')
return false
end
rescue WIN32OLERuntimeError
end
object = object.parentElement
end
true
end
end

David Schmidt

[EMAIL PROTECTED] wrote:
>
> Is there an easy way to determine if a control (a checkbox in my case) 
> is hidden?
>
> I have a checkbox that exists in a <TD> that (through several wrapped 
> divs) ends up being hidden sometimes. Is there an easy way to 
> determine this?
>
> I’ve tried:
>
> if $ie.hidden(:id, "control id”)
>
> and
>
> if $ie.hidden(:name, "control name”)
>
> And neither seems to work.
>
> Thanks,
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wtr-general mailing list
> Wtr-general@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to