Skip to content

Commit

Permalink
Merge pull request #578 from mseele/fix-issue-573
Browse files Browse the repository at this point in the history
Fix issue 573
  • Loading branch information
asolntsev committed Aug 7, 2017
2 parents 167f43a + 6855e48 commit 22aaecb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/codeborne/selenide/Condition.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,14 @@ public String toString() {
* @param expectedAttributeValue expected value of attribute
*/
public static Condition attribute(final String attributeName, final String expectedAttributeValue) {
return attribute(attributeName, expectedAttributeValue, true);
}

private static Condition attribute(final String attributeName, final String expectedAttributeValue, final boolean trim) {
return new Condition("attribute") {
@Override
public boolean apply(WebElement element) {
return expectedAttributeValue.equals(getAttributeValue(element, attributeName));
return expectedAttributeValue.equals(getAttributeValue(element, attributeName, trim));
}
@Override
public String toString() {
Expand All @@ -162,9 +166,9 @@ public String toString() {
};
}

private static String getAttributeValue(WebElement element, String attributeName) {
private static String getAttributeValue(WebElement element, String attributeName, boolean trim) {
String attr = element.getAttribute(attributeName);
return attr == null ? "" : attr.trim();
return attr == null ? "" : (trim ? attr.trim() : attr);
}

/**
Expand All @@ -179,7 +183,7 @@ public static Condition value(final String expectedValue) {
return new Condition("value") {
@Override
public boolean apply(WebElement element) {
return Html.text.contains(getAttributeValue(element, "value"), expectedValue);
return Html.text.contains(getAttributeValue(element, "value", true), expectedValue);
}
@Override
public String toString() {
Expand All @@ -193,7 +197,7 @@ public String toString() {
* @param value expected value of input field
*/
public static Condition exactValue(String value) {
return attribute("value", value);
return attribute("value", value, false);
}

/**
Expand Down

0 comments on commit 22aaecb

Please sign in to comment.