I recently needed to check the visibility of an element in a WatiN test and I came across a very helpful post by Ashley Tate. I turned his method into the following extension method which makes my tests nice and easy.
1: public static class ElementExtensions
2: {
3: public static bool IsDisplayed(this Element element)
4: {
5: if (string.Equals(element.Style.Display, "none"))
6: {
7: return false;
8: }
9: return element.Parent == null || element.Parent.IsDisplayed();
10: }
11: }
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.