Class WebTesterAssertions


  • public class WebTesterAssertions
    extends Object
    Assertions that revolve around a WebTester
    • Constructor Detail

      • WebTesterAssertions

        public WebTesterAssertions()
    • Method Detail

      • assertPageTitleEquals

        public static void assertPageTitleEquals​(net.sourceforge.jwebunit.junit.WebTester webTester,
                                                 String pageTitle)
        Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
        e.g. "Dashboard - Confluence"
        Parameters:
        webTester - The WebTester
        pageTitle - The title displayed before the first separator
      • assertPageTitleEquals

        public static void assertPageTitleEquals​(String reason,
                                                 net.sourceforge.jwebunit.junit.WebTester webTester,
                                                 String pageTitle)
        Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
        e.g. "Dashboard - Confluence"
        Parameters:
        reason - additional information about any assertion failure
        webTester - The WebTester
        pageTitle - The title displayed before the first separator
      • assertTitleEquals

        public static void assertTitleEquals​(net.sourceforge.jwebunit.junit.WebTester webTester,
                                             String pageTitle,
                                             String spaceTitle)
        Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
        e.g. "Home - Test Space - Confluence"
        Parameters:
        webTester - The WebTester
        pageTitle - The title displayed before the first separator
        spaceTitle - The title displayed for the tested space
      • assertTitleEquals

        public static void assertTitleEquals​(String reason,
                                             net.sourceforge.jwebunit.junit.WebTester webTester,
                                             String pageTitle,
                                             String spaceTitle)
        Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
        e.g. "Home - Test Space - Confluence"
        Parameters:
        reason - additional information about any assertion failure
        webTester - The WebTester
        pageTitle - The title displayed before the first separator
        spaceTitle - The title displayed for the tested space
      • assertPageTitle

        public static void assertPageTitle​(String pageTitle)
        Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
        e.g. "Dashboard - Confluence"
        Parameters:
        pageTitle - The title displayed before the first separator
      • assertPageTitleAnyOf

        public static void assertPageTitleAnyOf​(List<String> pageTitles)
        Asserts that the title is found within the specified collection of titles plus the site suffix (usually SITE_TITLE_SUFFIX).
        e.g. "Dashboard - Confluence"
        Parameters:
        pageTitles - The list of possible titles displayed before the first separator
      • assertPageTitle

        public static void assertPageTitle​(String reason,
                                           String pageTitle)
        Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
        e.g. "Dashboard - Confluence"
        Parameters:
        reason - additional information about any assertion failure
        pageTitle - The title displayed before the first separator
      • assertPageAndSpaceTitle

        public static void assertPageAndSpaceTitle​(String pageTitle,
                                                   String spaceTitle)
        Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
        e.g. "Home - Test Space - Confluence"
        Parameters:
        pageTitle - The title displayed before the first separator
        spaceTitle - The title displayed for the tested space
      • assertPageAndSpaceTitle

        public static void assertPageAndSpaceTitle​(String reason,
                                                   String pageTitle,
                                                   String spaceTitle)
        Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
        e.g. "Home - Test Space - Confluence"
        Parameters:
        reason - additional information about any assertion failure
        pageTitle - The title displayed before the first separator
        spaceTitle - The title displayed for the tested space
      • assertTextsPresentInOrder

        public static void assertTextsPresentInOrder​(String... texts)
        Asserts that all the given texts appear in the current response in the order in which they appear in the array.
        Parameters:
        texts - an array of strings expected to appear in the response
      • assertTextsPresentInOrder

        public static void assertTextsPresentInOrder​(String[] expected,
                                                     String[] unexpected)
        Asserts that all the given expected texts appear in the current response in the order in which they appear in the array, with none of the unexpected Strings occurring in-between.
        Parameters:
        expected - an array of strings expected to appear in the response
        unexpected - an array of string unexpected to appear in the response
      • assertTextPresentInPageSource

        public static void assertTextPresentInPageSource​(String text)
        Asserts that the given text is in the page source. Useful for testing non-html responses where assertTextPresent doesn't work.
        Parameters:
        text - the text to look for
      • assertTextNotPresentInPageSource

        public static void assertTextNotPresentInPageSource​(String text)
      • assertLinkPresentWithHref

        public static void assertLinkPresentWithHref​(String url)
      • assertLinkPresentWithAttribute

        public static void assertLinkPresentWithAttribute​(String name)
      • assertLinkNotPresentWithAttribute

        public static void assertLinkNotPresentWithAttribute​(String name)
      • assertLinkPresentWithAttribute

        public static void assertLinkPresentWithAttribute​(String name,
                                                          String value)
      • assertLinkPresentWithHrefContaining

        public static void assertLinkPresentWithHrefContaining​(String urlSubstring)
      • assertLinkNotPresentWithHrefContaining

        public static void assertLinkNotPresentWithHrefContaining​(String urlSubstring)
      • assertLinkPresentWithTextAndHref

        public static void assertLinkPresentWithTextAndHref​(String text,
                                                            String href)
      • assertStatusCode

        public static void assertStatusCode​(int expectedStatus)
      • assertStatusCode

        public static void assertStatusCode​(int expectedStatus,
                                            String failureMessage)
        Assert the status code and should the assertion fail then include the supplied failure message.
        Parameters:
        expectedStatus - the status to assert for
        failureMessage - the message to include should the assertion fail
      • assertServerResponseContains

        public static void assertServerResponseContains​(String string)
      • assertDoesNotContain

        public static void assertDoesNotContain​(String unexpectedSubstring,
                                                String actual)
      • assertStartsWith

        public static void assertStartsWith​(String expectedPrefix,
                                            String actual)
      • assertIsLoggedInAs

        public static void assertIsLoggedInAs​(User user)
      • assertImageIsPresentWithSrcUrlThatContains

        public static void assertImageIsPresentWithSrcUrlThatContains​(String imageName)
        Provide our own implementation of JWebUnit.assertImagePresent(String, String) that asserts the image name with a contains check rather than equals.
        Parameters:
        imageName - The path to the image (i.e. the src attribute value)