Class WebAssert
java.lang.Object
org.htmlunit.WebAssert
Utility class which contains standard assertions for HTML pages.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidMany HTML components can have anaccesskeyattribute which defines a hot key for keyboard navigation.static voidVerifies that all element IDs in the specified page are unique.static voidMany HTML elements are "tabbable" and can have atabindexattribute that determines the order in which the components are navigated when pressing the tab key.static voidassertElementNotPresent(HtmlPage page, String id) Verifies that the specified page does not contain an element with the specified ID.static voidassertElementNotPresentByXPath(HtmlPage page, String xpath) Verifies that the specified page does not contain an element matching the specified XPath expression.static voidassertElementPresent(HtmlPage page, String id) Verifies that the specified page contains an element with the specified ID.static voidassertElementPresentByXPath(HtmlPage page, String xpath) Verifies that the specified page contains an element matching the specified XPath expression.static voidassertFormNotPresent(HtmlPage page, String name) Verifies that the specified page does not contain a form with the specified name.static voidassertFormPresent(HtmlPage page, String name) Verifies that the specified page contains a form with the specified name.static voidassertInputContainsValue(HtmlPage page, String name, String value) Verifies that the input element with the specified name on the specified page contains the specified value.static voidassertInputDoesNotContainValue(HtmlPage page, String name, String value) Verifies that the input element with the specified name on the specified page does not contain the specified value.static voidassertInputNotPresent(HtmlPage page, String name) Verifies that the specified page does not contain an input element with the specified name.static voidassertInputPresent(HtmlPage page, String name) Verifies that the specified page contains an input element with the specified name.static voidassertLinkNotPresent(HtmlPage page, String id) Verifies that the specified page does not contain a link with the specified ID.static voidassertLinkNotPresentWithText(HtmlPage page, String text) Verifies that the specified page does not contain a link with the specified text.static voidassertLinkPresent(HtmlPage page, String id) Verifies that the specified page contains a link with the specified ID.static voidassertLinkPresentWithText(HtmlPage page, String text) Verifies that the specified page contains a link with the specified text.static voidassertTextNotPresent(HtmlPage page, String text) Verifies that the specified page does not contain the specified text.static voidassertTextNotPresentInElement(HtmlPage page, String text, String id) Verifies that the element on the specified page which matches the specified ID does not contain the specified text.static voidassertTextPresent(HtmlPage page, String text) Verifies that the specified page contains the specified text.static voidassertTextPresentInElement(HtmlPage page, String text, String id) Verifies that the element on the specified page which matches the specified ID contains the specified text.static voidassertTitleContains(HtmlPage page, String titlePortion) Verifies that the specified page's title contains the specified substring.static voidassertTitleEquals(HtmlPage page, String title) Verifies that the specified page's title equals the specified expected title.static voidassertTitleMatches(HtmlPage page, String regex) Verifies that the specified page's title matches the specified regular expression.static voidAssert that the specified parameter is not null.
-
Constructor Details
-
WebAssert
private WebAssert()Private to prevent instantiation.
-
-
Method Details
-
assertTitleEquals
-
assertTitleContains
-
assertTitleMatches
-
assertElementPresent
-
assertElementPresentByXPath
-
assertElementNotPresent
-
assertElementNotPresentByXPath
Verifies that the specified page does not contain an element matching the specified XPath expression.- Parameters:
page- the page to checkxpath- the XPath expression which is expected to not match an element in the page
-
assertTextPresent
-
assertTextPresentInElement
Verifies that the element on the specified page which matches the specified ID contains the specified text.- Parameters:
page- the page to checktext- the text to check forid- the ID of the element which is expected to contain the specified text
-
assertTextNotPresent
-
assertTextNotPresentInElement
Verifies that the element on the specified page which matches the specified ID does not contain the specified text.- Parameters:
page- the page to checktext- the text to check forid- the ID of the element which is expected to not contain the specified text
-
assertLinkPresent
-
assertLinkNotPresent
-
assertLinkPresentWithText
Verifies that the specified page contains a link with the specified text. The specified text may be a substring of the entire text contained by the link.- Parameters:
page- the page to checktext- the text which a link in the specified page is expected to contain
-
assertLinkNotPresentWithText
Verifies that the specified page does not contain a link with the specified text. The specified text may be a substring of the entire text contained by the link.- Parameters:
page- the page to checktext- the text which a link in the specified page is not expected to contain
-
assertFormPresent
-
assertFormNotPresent
-
assertInputPresent
-
assertInputNotPresent
-
assertInputContainsValue
Verifies that the input element with the specified name on the specified page contains the specified value.- Parameters:
page- the page to checkname- the name of the input element to checkvalue- the value to check for
-
assertInputDoesNotContainValue
Verifies that the input element with the specified name on the specified page does not contain the specified value.- Parameters:
page- the page to checkname- the name of the input element to checkvalue- the value to check for
-
assertAllTabIndexAttributesSet
Many HTML elements are "tabbable" and can have a
tabindexattribute that determines the order in which the components are navigated when pressing the tab key. To ensure good usability for keyboard navigation, all tabbable elements should have thetabindexattribute set.This method verifies that all tabbable elements have a valid value set for the
tabindexattribute.- Parameters:
page- the page to check
-
assertAllAccessKeyAttributesUnique
Many HTML components can have anaccesskeyattribute which defines a hot key for keyboard navigation. This method verifies that all theaccesskeyattributes on the specified page are unique.- Parameters:
page- the page to check
-
assertAllIdAttributesUnique
Verifies that all element IDs in the specified page are unique.- Parameters:
page- the page to check
-
notNull
-