-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vicdev
committed
Feb 10, 2017
1 parent
3202eca
commit 4407430
Showing
4 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/io/qameta/htmlelements/matcher/EnabledMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.qameta.htmlelements.matcher; | ||
|
||
import org.hamcrest.Description; | ||
import org.hamcrest.Factory; | ||
import org.hamcrest.Matcher; | ||
import org.hamcrest.TypeSafeMatcher; | ||
import org.openqa.selenium.WebDriverException; | ||
import org.openqa.selenium.WebElement; | ||
|
||
public class EnabledMatcher extends TypeSafeMatcher<WebElement> { | ||
|
||
private EnabledMatcher() { | ||
} | ||
|
||
@Override | ||
protected boolean matchesSafely(WebElement element) { | ||
try { | ||
return element.isEnabled(); | ||
} catch (WebDriverException e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public void describeTo(Description description) { | ||
description.appendText("element is enabled"); | ||
} | ||
|
||
@Override | ||
public void describeMismatchSafely(WebElement element, Description mismatchDescription) { | ||
mismatchDescription.appendText("element ").appendValue(element).appendText(" is not enabled"); | ||
} | ||
|
||
@Factory | ||
public static Matcher<WebElement> enabled() { | ||
return new EnabledMatcher(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/test/java/io/qameta/htmlelements/example/element/SearchArrow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters