Package org.htmlunit
Class WebAssert
java.lang.Object
org.htmlunit.WebAssert
Utility class which contains standard assertions for HTML pages.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Many HTML components can have anaccesskey
attribute which defines a hot key for keyboard navigation.static void
Verifies that all element IDs in the specified page are unique.static void
Many HTML elements are "tabbable" and can have atabindex
attribute that determines the order in which the components are navigated when pressing the tab key.static void
assertElementNotPresent
(HtmlPage page, String id) Verifies that the specified page does not contain an element with the specified ID.static void
assertElementNotPresentByXPath
(HtmlPage page, String xpath) Verifies that the specified page does not contain an element matching the specified XPath expression.static void
assertElementPresent
(HtmlPage page, String id) Verifies that the specified page contains an element with the specified ID.static void
assertElementPresentByXPath
(HtmlPage page, String xpath) Verifies that the specified page contains an element matching the specified XPath expression.static void
assertFormNotPresent
(HtmlPage page, String name) Verifies that the specified page does not contain a form with the specified name.static void
assertFormPresent
(HtmlPage page, String name) Verifies that the specified page contains a form with the specified name.static void
assertInputContainsValue
(HtmlPage page, String name, String value) Verifies that the input element with the specified name on the specified page contains the specified value.static void
assertInputDoesNotContainValue
(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 void
assertInputNotPresent
(HtmlPage page, String name) Verifies that the specified page does not contain an input element with the specified name.static void
assertInputPresent
(HtmlPage page, String name) Verifies that the specified page contains an input element with the specified name.static void
assertLinkNotPresent
(HtmlPage page, String id) Verifies that the specified page does not contain a link with the specified ID.static void
assertLinkNotPresentWithText
(HtmlPage page, String text) Verifies that the specified page does not contain a link with the specified text.static void
assertLinkPresent
(HtmlPage page, String id) Verifies that the specified page contains a link with the specified ID.static void
assertLinkPresentWithText
(HtmlPage page, String text) Verifies that the specified page contains a link with the specified text.static void
assertTextNotPresent
(HtmlPage page, String text) Verifies that the specified page does not contain the specified text.static void
assertTextNotPresentInElement
(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 void
assertTextPresent
(HtmlPage page, String text) Verifies that the specified page contains the specified text.static void
assertTextPresentInElement
(HtmlPage page, String text, String id) Verifies that the element on the specified page which matches the specified ID contains the specified text.static void
assertTitleContains
(HtmlPage page, String titlePortion) Verifies that the specified page's title contains the specified substring.static void
assertTitleEquals
(HtmlPage page, String title) Verifies that the specified page's title equals the specified expected title.static void
assertTitleMatches
(HtmlPage page, String regex) Verifies that the specified page's title matches the specified regular expression.static void
Assert that the specified parameter is not null.
-
Method Details
-
assertTitleEquals
Verifies that the specified page's title equals the specified expected title.- Parameters:
page
- the page to checktitle
- the expected title
-
assertTitleContains
Verifies that the specified page's title contains the specified substring.- Parameters:
page
- the page to checktitlePortion
- the substring which the page title is expected to contain
-
assertTitleMatches
Verifies that the specified page's title matches the specified regular expression.- Parameters:
page
- the page to checkregex
- the regular expression that the page title is expected to match
-
assertElementPresent
Verifies that the specified page contains an element with the specified ID.- Parameters:
page
- the page to checkid
- the expected ID of an element in the page
-
assertElementPresentByXPath
Verifies that the specified page contains an element matching the specified XPath expression.- Parameters:
page
- the page to checkxpath
- the XPath expression which is expected to match an element in the page
-
assertElementNotPresent
Verifies that the specified page does not contain an element with the specified ID.- Parameters:
page
- the page to checkid
- the ID of an element which expected to not exist on the page
-
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
Verifies that the specified page contains the specified text.- Parameters:
page
- the page to checktext
- the text to check for
-
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
Verifies that the specified page does not contain the specified text.- Parameters:
page
- the page to checktext
- the text to check for
-
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
Verifies that the specified page contains a link with the specified ID.- Parameters:
page
- the page to checkid
- the ID of the link which the page is expected to contain
-
assertLinkNotPresent
Verifies that the specified page does not contain a link with the specified ID.- Parameters:
page
- the page to checkid
- the ID of the link which the page is expected to not contain
-
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
Verifies that the specified page contains a form with the specified name.- Parameters:
page
- the page to checkname
- the expected name of a form on the page
-
assertFormNotPresent
Verifies that the specified page does not contain a form with the specified name.- Parameters:
page
- the page to checkname
- the name of a form which should not exist on the page
-
assertInputPresent
Verifies that the specified page contains an input element with the specified name.- Parameters:
page
- the page to checkname
- the name of the input element to look for
-
assertInputNotPresent
Verifies that the specified page does not contain an input element with the specified name.- Parameters:
page
- the page to checkname
- the name of the input element to look for
-
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
tabindex
attribute 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 thetabindex
attribute set.This method verifies that all tabbable elements have a valid value set for the
tabindex
attribute.- Parameters:
page
- the page to check
-
assertAllAccessKeyAttributesUnique
Many HTML components can have anaccesskey
attribute which defines a hot key for keyboard navigation. This method verifies that all theaccesskey
attributes 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
Assert that the specified parameter is not null. Throw a NullPointerException if a null is found.- Parameters:
description
- the description to pass into the NullPointerExceptionobject
- the object to check for null
-