@@ -73,17 +73,23 @@ def clear(self):
73
73
self ._execute (Command .CLEAR_ELEMENT )
74
74
75
75
def get_attribute (self , name ):
76
- """Gets the attribute value.
76
+ """Gets the given attribute or property of the element.
77
+
78
+ This method will return the value of the given property if this is set,
79
+ otherwise it returns the value of the attribute with the same name if
80
+ that exists, or None.
81
+
82
+ Values which are considered truthy, that is equals "true" or "false",
83
+ are returned as booleans. All other non-None values are returned as
84
+ strings. For attributes or properties which does not exist, None is returned.
77
85
78
86
:Args:
79
- - name - name of the attribute property to retieve .
87
+ - name - Name of the attribute/ property to retrieve .
80
88
81
89
Example::
82
90
83
- # Check if the 'active' css class is applied to an element.
84
- is_active = "active" in target_element.get_attribute("class")
85
-
86
- """
91
+ # Check if the "active" CSS class is applied to an element.
92
+ is_active = "active" in target_element.get_attribute("class")"""
87
93
resp = self ._execute (Command .GET_ELEMENT_ATTRIBUTE , {'name' : name })
88
94
attributeValue = ''
89
95
if resp ['value' ] is None :
@@ -92,7 +98,6 @@ def get_attribute(self, name):
92
98
attributeValue = resp ['value' ]
93
99
if name != 'value' and attributeValue .lower () in ('true' , 'false' ):
94
100
attributeValue = attributeValue .lower ()
95
-
96
101
return attributeValue
97
102
98
103
def is_selected (self ):
0 commit comments