@@ -1033,12 +1033,12 @@ public String toString() {
10331033 }
10341034
10351035 /**
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
10371037 *
10381038 * @param element used to check its parameters
10391039 * @param property property name
10401040 * @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
10421042 */
10431043 public static ExpectedCondition <Boolean > domPropertyToBe (final WebElement element ,
10441044 final String property ,
@@ -1060,6 +1060,34 @@ public String toString() {
10601060 };
10611061 }
10621062
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+
10631091 /**
10641092 * An expectation for checking given WebElement has attribute with a specific value
10651093 *
0 commit comments