Class AbstractEditorContentWebDriverTest


  • public abstract class AbstractEditorContentWebDriverTest
    extends Object
    Base class for Confluence Editor Content WebDriver tests Makes easier to run all the editor content related tests in the same Confluence editor page sequentially.
    • Field Detail

      • editor

        protected static Editor editor
      • OS_CTRL_KEY

        protected static final String OS_CTRL_KEY
      • ignoreRule

        public com.atlassian.webdriver.testing.rule.IgnoreBrowserRule ignoreRule
      • webDriverScreenshotRule

        public com.atlassian.webdriver.testing.rule.WebDriverScreenshotRule webDriverScreenshotRule
      • logPageSourceRule

        public com.atlassian.webdriver.testing.rule.LogPageSourceRule logPageSourceRule
    • Constructor Detail

      • AbstractEditorContentWebDriverTest

        public AbstractEditorContentWebDriverTest()
    • Method Detail

      • setupEditor

        public static void setupEditor()
      • tearDownEditor

        public static void tearDownEditor()
      • clearContent

        public void clearContent()
      • ignoreBrowserDecorator

        protected void ignoreBrowserDecorator​(Runnable runnable,
                                              com.atlassian.pageobjects.browser.Browser... ignoredBrowsers)
        Used for comet assertions in order to allow specific private assertions to be ignored on certain browsers
      • ignoreBrowserDecoratorSetup

        protected void ignoreBrowserDecoratorSetup()
      • ignoreBrowserDecoratorTearDown

        protected void ignoreBrowserDecoratorTearDown()
      • assertEditorHtml

        protected void assertEditorHtml​(String html)
        Asserts that the HTML content of the editor matches the given HTML - use with care, HTML produced by the editor can be inconsistent across browsers, and HTML content returned by TinyMCE is 'cleaned up'. If you don't need to verify that the editor doesn't contain additional content, you should use assertEditorHtmlContains(String) instead.
        Parameters:
        html - HTML content to match
        Since:
        5.6
      • assertEditorHtml

        protected void assertEditorHtml​(String html,
                                        boolean normalizeSpaces)
        Asserts that the HTML content of the editor matches the given HTML - use with care, HTML produced by the editor can be inconsistent across browsers, and HTML content returned by TinyMCE is 'cleaned up'. If you don't need to verify that the editor doesn't contain additional content, you should use assertEditorHtmlContains(String) instead.
        Parameters:
        html - HTML content to match
        normalizeSpaces - boolean indicating whether spaces should be normalised
        Since:
        5.6
      • assertEditorHtmlContains

        protected void assertEditorHtmlContains​(String html)
        Asserts that the HTML content of the editor contains the given HTML - use with care, HTML produced by the editor can be inconsistent across browsers, and HTML content returned by TinyMCE is 'cleaned up'.
        Parameters:
        html - HTML content to match
        Since:
        5.6
      • assertEditorHtmlDoesNotContain

        protected void assertEditorHtmlDoesNotContain​(String html)
        Asserts that the HTML content of the editor does not contain the given HTML - use with care, HTML produced by the editor can be inconsistent across browsers.
        Parameters:
        html - HTML content to search for
        Since:
        5.6
      • assertEditorText

        protected void assertEditorText​(String text)
        Asserts that the textual content of the editor matches the given string - use with care, there can be spacing inconsistencies across browsers.
        Parameters:
        text - Text to match
        Since:
        5.6
      • assertElementAttributeValue

        @Deprecated
        protected void assertElementAttributeValue​(String selector,
                                                   String attributeName,
                                                   String expectedAttributeValue)
        Asserts that the value of the specified attribute belonging to the element matching the given selector matches the expected attribute value.
        Parameters:
        selector - CSS selector for locating element in the editor content
        attributeName - Name of the attribute to read the value for
        expectedAttributeValue - Expected value for the attribute
        Since:
        5.6
      • assertElementAttributeValueMatches

        protected void assertElementAttributeValueMatches​(String selector,
                                                          String attributeName,
                                                          org.hamcrest.Matcher<String> attributeValueMatcher)
        Since:
        5.9
      • assertElementNumberOfMatches

        protected void assertElementNumberOfMatches​(int quantity,
                                                    String selector)
        Asserts that the number of matches for a particular selector query within the editor content is consistent with the expected quantity
        Parameters:
        quantity - The number of expected matches
        selector - CSS selector to be used for matching elements in the editor content
        Since:
        5.6
      • assertElementText

        protected void assertElementText​(String text,
                                         String selector)
        Asserts that text in the provided selection within the editor content matches the given string.
        Parameters:
        text - Text we expect to match
        selector - CSS selector for locating element in the editor content
        Since:
        5.6
      • assertElementText

        protected void assertElementText​(String message,
                                         String text,
                                         String selector)
        Asserts that text in the provided selection within the editor content matches the given string.
        Parameters:
        message - Error message
        text - Text we expect to match
        selector - CSS selector for locating element in the editor content
        Since:
        5.6
      • assertElementTextContains

        protected void assertElementTextContains​(String text,
                                                 String selector)
        Asserts that text in the provided selection within the editor content contains the given string.
        Parameters:
        text - Text we expect the element to contain
        selector - CSS selector for locating element in the editor content
        Since:
        5.6
      • clickOnElement

        protected void clickOnElement​(String selector)
        Simulates clicking on the matched element in the editor content.
        Parameters:
        selector - CSS selector for locating element in the editor content
        Since:
        5.6
      • insertAndWaitForFixture

        protected void insertAndWaitForFixture​(String fixture)
        Sets the content of the editor using the TinyMCE API and waits for the exact same content to be present - if the content being set in the editor contains any HTML tags it's safer to use insertAndWaitForFixture(String, String) instead.
        Parameters:
        fixture - Normalised HTML content to be set in the editor
        Since:
        5.6
      • insertAndWaitForFixture

        protected void insertAndWaitForFixture​(String fixture,
                                               String htmlToWaitFor)
        Sets the content of the editor using the TinyMCE API and waits for the specified content to be present. It's advisable to use a simple (perhaps text-only) portion of the content to be inserted for checking that the editor content has been updated, as TinyMCE may apply some changes to the supplied HTML.
        Parameters:
        fixture - HTML content to be set in the editor
        htmlToWaitFor - Content to be used for checking that the editor has been updated
        Since:
        5.6
      • placeCursorAtTheEndOfElement

        protected void placeCursorAtTheEndOfElement​(String selector)
        Positions the cursor at the end of the first matched element for the provided CSS selector.
        Parameters:
        selector - CSS selector to be used for positioning the cursor.
        Since:
        5.6
      • placeCursorAtTheStartOfElement

        protected void placeCursorAtTheStartOfElement​(String selector)
        Positions the cursor at the start of the first matched element for the provided CSS selector.
        Parameters:
        selector - CSS selector to be used for positioning the cursor.
        Since:
        5.6
      • pressUp

        protected void pressUp()
        Simulates pressing the up arrow key on the TinyMCE iframe.
        Since:
        5.6
      • pressDown

        protected void pressDown()
        Simulates pressing the down arrow key on the TinyMCE iframe.
        Since:
        5.6
      • pressLeft

        protected void pressLeft()
        Simulates pressing the left arrow key on the TinyMCE iframe.
        Since:
        5.6
      • pressRight

        protected void pressRight()
        Simulates pressing the right arrow key on the TinyMCE iframe.
        Since:
        5.6
      • pressBackspace

        protected void pressBackspace()
        Simulates pressing backspace on the TinyMCE iframe.
        Since:
        5.6
      • pressDelete

        protected void pressDelete()
        Simulates pressing the delete key on the TinyMCE iframe.
        Since:
        5.6
      • pressEnter

        protected void pressEnter()
        Simulates pressing the enter key on the TinyMCE iframe. Please make sure you don't want to use pressReturn instead
        Since:
        5.6
      • pressReturn

        protected void pressReturn()
        Simulates pressing the return key on the TinyMCE iframe.
        Since:
        5.6
      • pressEsc

        protected void pressEsc()
        Simulates pressing the escape key on the TinyMCE iframe.
        Since:
        5.6
      • pressMultipleKeys

        protected void pressMultipleKeys​(String keysChord)
        Simulates pressing multiple keys at once on the TinyMCE iframe.
        Parameters:
        keysChord - A representation of keys to press - see Keys.chord(CharSequence...)
        Since:
        5.6
      • pressTab

        protected void pressTab()
        Simulates pressing the tab key on the TinyMCE iframe.
        Since:
        5.6
      • undo

        protected void undo()
        Executes the undo editor command.
        Since:
        5.6
      • typeInTheEditor

        protected void typeInTheEditor​(String string)
        Simulates typing in the editor.
        Parameters:
        string - Content to type into the editor
        Since:
        5.6