public class CustomMatchers extends Object
| Constructor and Description |
|---|
CustomMatchers() |
| Modifier and Type | Method and Description |
|---|---|
static org.hamcrest.Matcher<InBrowser> |
hasElement(Path el)
Successful if the browser has an element that corresponds to the given path.
|
static HasElements |
hasElements(Path path)
Successful if element is present in the browser or a W3C document.
|
static org.hamcrest.Matcher<InBrowser> |
hasNoElement(Path el)
Successful if given browser has no elements that correspond to the given path.
|
static HasText |
hasText(String text)
Successful if element has the text equal to the given parameter in the browser/document.
|
static org.hamcrest.Matcher<Path> |
isAbsentFrom(Document document)
Successful if given document has no elements that correspond to the given path.
|
static org.hamcrest.Matcher<Path> |
isAbsentFrom(InBrowser browser)
Successful if given browser has no elements that correspond to the given path.
|
static org.hamcrest.Matcher<Path> |
isDisplayedIn(InBrowser browser)
Successful if given element is present and displayed in the browser.
|
static org.hamcrest.Matcher<Path> |
isEnabledIn(InBrowser browser)
Successful if given element is present and enabled in the browser.
|
static org.hamcrest.Matcher<Path> |
isNotDisplayedIn(InBrowser browser)
Successful if given element is either not present, or present and not displayed in the browser.
|
static IsPresent |
isPresent()
Successful if element is present in the browser/document.
|
static IsPresentNTimes |
isPresent(int nTimes)
Successful if the the element appears the expected number of times in the browser or W3C document.
|
static org.hamcrest.Matcher<Path> |
isPresentIn(Document document)
Successful if given element is present in the document.
|
static org.hamcrest.Matcher<Path> |
isPresentIn(InBrowser browser)
Successful if given element is present in the browser.
|
static org.hamcrest.Matcher<Path> |
isSelectedIn(InBrowser browser)
Successful if given element is present and selected in the browser.
|
public static org.hamcrest.Matcher<InBrowser> hasElement(Path el)
assertThat( browser, hasElement(el));
el - the path to findpublic static IsPresentNTimes isPresent(int nTimes)
InBrowser browser = new InBrowser(driver);
assertThat( myElement, ispresent(5).timesOrMoreIn(browser));
assertThat( myElement, ispresent(5).timesIn(browser));
assertThat( myElement, ispresent(5).timesOrLessIn(browser));
Same examples apply in case you have a Document (org.w3c.dom.Document).nTimes - - the reference number of times to be matched against. See examples.public static IsPresent isPresent()
assertThat( path, isPresent().in(browser));
public static HasText hasText(String text)
assertThat( path, hasText().in(browser));
text - the text to equal to (case insensitive)public static HasElements hasElements(Path path)
assertThat(browser, hasElements(path).present(5).times());
assertThat(browser, hasElements(path).present(5).timesOrMore());
assertThat(document, hasElements(path).present(5).timesOrLess());
path - The path of the elements to findpublic static org.hamcrest.Matcher<Path> isPresentIn(InBrowser browser)
assertThat( path, isPresentIn(browser));
browser - the browser instance to look inpublic static org.hamcrest.Matcher<Path> isPresentIn(Document document)
assertThat( path, isPresentIn(document));
document - - a W#C documentpublic static org.hamcrest.Matcher<Path> isDisplayedIn(InBrowser browser)
assertThat( path, isDisplayedIn(browser));
browser - the browser instance to look inpublic static org.hamcrest.Matcher<Path> isNotDisplayedIn(InBrowser browser)
assertThat( path, isNotDisplayedIn(browser)); browser - the browser instance to look inpublic static org.hamcrest.Matcher<Path> isSelectedIn(InBrowser browser)
assertThat( path, isSelectedIn(browser));
browser - the browser instance to look inpublic static org.hamcrest.Matcher<Path> isEnabledIn(InBrowser browser)
assertThat( path, isEnabledIn(browser));
browser - the browser instance to look inpublic static org.hamcrest.Matcher<InBrowser> hasNoElement(Path el)
assertThat( browser, hasNoElement(path));
el - - the path that is expected not to exist in the browserpublic static org.hamcrest.Matcher<Path> isAbsentFrom(InBrowser browser)
assertThat( path, isAbsentFrom(browser));
browser - the browser instance to look inpublic static org.hamcrest.Matcher<Path> isAbsentFrom(Document document)
assertThat( path, isAbsentFrom(doc));
document - - a W3C documentCopyright © 2019. All rights reserved.