@@ -64,18 +64,46 @@ public void ErrorGetElementAttributeStaleElement()
64
64
[ TestMethod ]
65
65
public void GetValidElementAttribute ( )
66
66
{
67
- // NOTE: HelpText is currently the only supported GetAttribute method. There are
68
- // no known examples of non-null HelpText, so this should be replaced with
69
- // a different attribute once more are supported.
70
- string helpText = alarmTabElement . GetAttribute ( "HelpText" ) ;
71
- Assert . AreEqual ( helpText , null ) ;
67
+ // NOTE: The attributes below are only a subset of supported attributes.
68
+ // Use inspect.exe to identify all available attributes of an element
69
+ var element = alarmTabElement ;
70
+
71
+ // Fixed value string attributes
72
+ Assert . AreEqual ( element . GetAttribute ( "Name" ) , "Alarm" ) ;
73
+ Assert . AreEqual ( element . GetAttribute ( "AutomationId" ) , "AlarmPivotItem" ) ;
74
+ Assert . AreEqual ( element . GetAttribute ( "FrameworkId" ) , "XAML" ) ;
75
+ Assert . AreEqual ( element . GetAttribute ( "ClassName" ) , "PivotItem" ) ;
76
+ Assert . AreEqual ( element . GetAttribute ( "LegacyName" ) , "Alarm" ) ; // Shows as Legacy|Accessible.Name in inspect.exe
77
+
78
+ // Fixed value boolean attributes
79
+ Assert . AreEqual ( element . GetAttribute ( "IsEnabled" ) , "True" ) ;
80
+ Assert . AreEqual ( element . GetAttribute ( "IsKeyboardFocusable" ) , "True" ) ;
81
+ Assert . AreEqual ( element . GetAttribute ( "IsControlElement" ) , "True" ) ;
82
+
83
+ // Arbitrary value attributes
84
+ Assert . IsTrue ( System . Convert . ToInt32 ( element . GetAttribute ( "ProcessId" ) ) > 0 ) ;
85
+ Assert . IsFalse ( string . IsNullOrEmpty ( element . GetAttribute ( "RuntimeId" ) ) ) ;
86
+
87
+ // Arbitrary value array attributes
88
+ Assert . IsFalse ( string . IsNullOrEmpty ( element . GetAttribute ( "ClickablePoint" ) ) ) ;
89
+ var boundingRectangle = element . GetAttribute ( "BoundingRectangle" ) ;
90
+ Assert . IsTrue ( boundingRectangle . Contains ( "Top" ) ) ;
91
+ Assert . IsTrue ( boundingRectangle . Contains ( "Left" ) ) ;
92
+ Assert . IsTrue ( boundingRectangle . Contains ( "Width" ) ) ;
93
+ Assert . IsTrue ( boundingRectangle . Contains ( "Height" ) ) ;
94
+
95
+ // Pattern specific attribute that may be used along with element.Selected property etc.
96
+ Assert . AreEqual ( element . GetAttribute ( "SelectionItem.IsSelected" ) , element . Selected . ToString ( ) ) ;
97
+ Assert . AreEqual ( element . GetAttribute ( "IsSelectionItemPatternAvailable" ) , "True" ) ;
98
+ Assert . AreEqual ( element . GetAttribute ( "IsSelectionPatternAvailable" ) , "False" ) ;
72
99
}
73
100
74
101
[ TestMethod ]
75
102
public void GetInvalidElementAttribute ( )
76
103
{
77
- string helpText = alarmTabElement . GetAttribute ( "InvalidAttribute" ) ;
78
- Assert . AreEqual ( helpText , null ) ;
104
+ // Getting the value of an invalid attribute should return null
105
+ string invalidAttribute = alarmTabElement . GetAttribute ( "InvalidAttribute" ) ;
106
+ Assert . AreEqual ( invalidAttribute , null ) ;
79
107
}
80
108
}
81
109
}
0 commit comments