@@ -1033,12 +1033,12 @@ public String toString() {
1033
1033
}
1034
1034
1035
1035
/**
1036
- * An expectation for checking given WebElement has property with a specific value
1036
+ * An expectation for checking given WebElement has DOM property with a specific value
1037
1037
*
1038
1038
* @param element used to check its parameters
1039
1039
* @param property property name
1040
1040
* @param value used as expected property value
1041
- * @return Boolean true when element has property with the value
1041
+ * @return Boolean true when element has DOM property with the value
1042
1042
*/
1043
1043
public static ExpectedCondition <Boolean > domPropertyToBe (final WebElement element ,
1044
1044
final String property ,
@@ -1060,6 +1060,34 @@ public String toString() {
1060
1060
};
1061
1061
}
1062
1062
1063
+ /**
1064
+ * An expectation for checking given WebElement has DOM attribute with a specific value
1065
+ *
1066
+ * @param element used to check its parameters
1067
+ * @param attribute attribute name
1068
+ * @param value used as expected attribute value
1069
+ * @return Boolean true when element has DOM attribute with the value
1070
+ */
1071
+ public static ExpectedCondition <Boolean > domAttributeToBe (final WebElement element ,
1072
+ final String attribute ,
1073
+ final String value ) {
1074
+ return new ExpectedCondition <Boolean >() {
1075
+ private String currentValue = null ;
1076
+
1077
+ @ Override
1078
+ public Boolean apply (WebDriver driver ) {
1079
+ currentValue = element .getDomAttribute (attribute );
1080
+ return value .equals (currentValue );
1081
+ }
1082
+
1083
+ @ Override
1084
+ public String toString () {
1085
+ return String .format (attribute + " to be \" %s\" . Current " + attribute + ": \" %s\" " , value ,
1086
+ currentValue );
1087
+ }
1088
+ };
1089
+ }
1090
+
1063
1091
/**
1064
1092
* An expectation for checking given WebElement has attribute with a specific value
1065
1093
*
0 commit comments