com.atlassian.confluence.selenium.client
Class TinyMce

java.lang.Object
  extended by com.atlassian.confluence.selenium.client.TinyMce

public class TinyMce
extends java.lang.Object


Nested Class Summary
static class TinyMce.Bookmark
          Represents a TinyMCE bookmark.
static class TinyMce.Format
           
static class TinyMce.Position
           
static class TinyMce.ShortCut
           
static class TinyMce.SimpleToolbarButton
           
 
Field Summary
static char NBSP
           
static java.lang.String TINYMCE_LOCATOR
           
static java.lang.String TOOLBAR_LOCATOR
           
 
Constructor Summary
TinyMce(ConfluenceSeleniumClient client, Editor editor)
           
 
Method Summary
 void clickFormatMenuLink()
           
 void clickHorizontalRuler()
           
 InsertCharacterDialog clickInsertCharacter()
           
 EmoticonPickerPopup clickInsertEmoticon()
           
 InsertTablePopup clickInsertTable()
           
 void clickOutsideEditor()
          Used for clicking something outside of the TinyMCE editor that is (currently) known to not have any click-handler on it.
 void clickSelectedColor()
           
 KeyboardShortcutHelpDialog clickShortcutHelpDialog()
           
 void clickToolbarButton(TinyMce.SimpleToolbarButton button)
           
 void copyAndPaste(java.lang.String selector)
          Copies the content specified by the selector, and pastes it before the content.
 void dispatchClickEventForSelector(java.lang.String selector)
          Triggers ed.onClick.dispatch on TinyMCE
 void editorContentFocus()
           
 java.lang.String getAttributeForSelector(java.lang.String selector, java.lang.String attribute)
          Returns the value of the given attribute for the given selector.
 TinyMce.Bookmark getBookmark()
           
 ConfluenceSeleniumClient getClient()
           
 java.lang.String getContent()
          Returns the current content of the Editor as HTML.
 java.lang.String getContent(java.lang.String selector, boolean removeNewLines)
          Returns the current content specified by the selector from the Editor as HTML.
 java.lang.String getContentIncludingNode(java.lang.String selector)
          Returns the current content specified by the selector from the Editor as HTML, including the selector itself.
 java.lang.String getCssAttributeForSelector(java.lang.String selector, java.lang.String attribute)
          Returns the value of the given attribute for the given selector.
 java.lang.String getCurrentSelectionText()
          Returns the text of the current editor selection.
 java.lang.String getExpressionValue(java.lang.String expression)
          Makes the TinyMCE doc available to the passed expression and evaluates it, returning the string result.
 java.lang.String getFirstRowSelector()
           
 java.lang.String getFirstTextColor()
          Gets the color of the first span with color in the style attribute.
 java.lang.String getImageSelector(boolean thumbnail)
          Returns the TinyMce selector for images in the editor.
 java.lang.String getLastRowSelector()
           
static java.lang.String getLocatorForTags(java.lang.String tagNames, com.atlassian.selenium.Browser browser)
          Returns a selenium locator or jQuery selector for the specified html tag in the TinyMCE editor.
 java.lang.String getMacroBodyText(java.lang.String macroName)
          Returns the body text of the macro.
 int getNumberOfCols()
           
 int getNumberOfRows()
           
 java.lang.String getRowSelector(int row)
           
 java.lang.String getSelectedColor()
           
 java.lang.String getSelectedColorDisplayColor()
           
 int getSelectorCount(java.lang.String selector)
          Returns the number of elements present in the editor specified by the given selector.
 java.lang.String getSelectorPresentScript(java.lang.String selector)
          Returns a javascript function that checks for the presence of an element with given jquery selector in the TinyMCE editor.
 java.lang.String getSelectorScript(java.lang.String selector)
          Returns a javascript function that checks for the presence of an element with given jquery selector in the TinyMCE editor.
 java.lang.String getTextAfterMacro(java.lang.String macroName)
          Returns the text in the Paragraph element after the macro (or its wrapper).
 java.lang.String getTextBeforeMacro(java.lang.String macroName)
          Returns the text in the Paragraph element before the macro (or its wrapper).
 java.lang.String getTextInTableCell(int row, int col)
           
 java.lang.String getToolbarButtonId(TinyMce.SimpleToolbarButton button)
           
 boolean isAutocompleteDropdownPresent()
          Checks whether the autocomplete dropdown is present.
 boolean isCellHighlighted(int row, int column, java.lang.String colour)
          Checks if the row and column is highlighted.
 boolean isColumnHeading(int column)
          Checks if the nth column is column row.
 boolean isExternalImagePresent(java.lang.String image)
          Returns true if the given attachment is present in the RTE.
 boolean isImagePresent(Attachment attachment)
          Returns true if the given attachment is present in the RTE.
 boolean isLeftAligned(java.lang.String selector)
          Checks that the given selector is left-aligned in the editor.
 boolean isMacroPresent(Macro macro)
          Returns true if a macro with given name is present in the editor.
 boolean isMacroPresent(java.lang.String macroName)
           
 boolean isMacroPresent(java.lang.String macroName, java.lang.String parameters)
           
 boolean isMacroPresent(java.lang.String macroName, java.lang.String parameters, java.lang.String bodyText)
           
 boolean isMacroPresent(java.lang.String macroName, java.lang.String parameters, java.lang.String bodyText, java.lang.String defaultParameter)
          Returns true if the macro with given parameters and body text, is present in the editor.
 boolean isMacroPropertyPanelPresent()
           
 boolean isRightAligned(java.lang.String selector)
          Checks that the given selector is right-aligned in the editor.
 boolean isRowHeading(int row)
          Checks if the nth row is a heading row
 boolean isRowHighlighted()
          Checks if the first row in the table is a heading row
 boolean isSelectorPresent(java.lang.String selector)
           
 boolean isTableHeaderRow(int row)
           
 boolean isTableNormalRow(int row)
           
 boolean isTablePresent()
           
 boolean isToolbarButtonActive(TinyMce.SimpleToolbarButton button)
           
 boolean isToolbarButtonEnabled(TinyMce.SimpleToolbarButton button)
           
 EditorInsertMenu openInsertMenu()
           
 EditorMoreMenu openMoreMenu()
           
 void pasteContent(java.lang.String html)
          Pastes the content as though it came from the clipboard.
 void placeCursor(java.lang.String selector, int position)
          Positions the cursor at the specified position in the first matched element for the provided CSS selector.
 void placeCursorAtStart(java.lang.String selector)
          Positions the cursor at the start of the first matched element for the provided CSS selector.
 void pressBackspace()
          Types the "Backspace" key at the current cursor position.
 void pressDown()
          Types the "Down arrow" key at the current cursor position.
 void pressEnter()
          Types the "Enter" key at the current cursor position.
 void pressEscape()
          Types the "Escape" key at the current cursor position.
 void pressShortcut(TinyMce.ShortCut shortCut)
           
 void pressShortcut(TinyMce.SimpleToolbarButton button)
           
 void pressUp()
          Types the "Up arrow" key at the current cursor position.
 void putCursorAtStartOfElementWithSelectorAndIndex(java.lang.String selector, int elementIndex)
          Place the cursor at the start of the element matching the given selector and index.
 void putCursorAtStartOfFirstElementWithSelector(java.lang.String selector)
          Place the cursor at the start of the first element matching the given selector.
 void scrollTopTo(int scrollTop)
          Scroll the RTE vertically to a certain position.
 void selectEditorFrame()
          Selects the TinyMCE iframe.
 void selectElementWithSelectorAndIndex(java.lang.String selector, int elementIndex)
          Select the nth element matching the given selector.
 void selectEmptyFirstParagraph()
           
 void selectFirstElementWithSelector(java.lang.String selector)
          Select the first element matching the given selector.
 void selectFirstParagraph()
           
 void selectFormat(TinyMce.Format format)
           
 MacroPropertyPanel selectMacro(java.lang.String macroName)
           
 MacroPropertyPanel selectMacro(java.lang.String macroName, java.lang.Runnable waitFor)
           
 void selectMainFrame()
          Selects the main/top frame for Confluence.
 void selectTextColor(java.lang.String rgbColor)
           
 void setContent(java.lang.String content)
           
 void setContentForSelector(java.lang.String selector, java.lang.String text)
          Sets the passed text in the RTE element matching the selector.
 void setHtmlContent(java.lang.String html)
          Used by tests rather than to replicate user behaviour.
 void toggleSourceMode()
           
 EditorAutocomplete triggerAutocomplete(TinyMce.ShortCut shortCut)
          Launches the autocomplete by pressing a shortcut key combination at the current cursor position.
 void type(java.lang.String content)
          Only works for Firefox, and period doesn't work.
 void typeWithFullKeyEvents(java.lang.String content)
          Only works for Firefox, and period doesn't work.
 void waitForImage(Attachment image)
          Wait for the specified image to load.
 void waitForMacroPresent(java.lang.String macroName)
           
 void waitForSelectorCount(java.lang.String selector, int count)
           
 void waitForSelectorPresent(java.lang.String selector)
          Wait for the given jQuery selector to be present in the TinyMCE editor.
 void waitForSelectorPresentWithText(java.lang.String selector, int index, java.lang.String bodyText)
           
 void waitForSelectorPresentWithText(java.lang.String selector, java.lang.String bodyText)
           
 void waitForTableCellPresent()
           
 void waitForTableHeadingCellPresent()
           
 java.lang.Boolean wasInsertedCorrectDirection(TinyMce.Position pos, int selectedRow)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TINYMCE_LOCATOR

public static final java.lang.String TINYMCE_LOCATOR
See Also:
Constant Field Values

TOOLBAR_LOCATOR

public static final java.lang.String TOOLBAR_LOCATOR
See Also:
Constant Field Values

NBSP

public static final char NBSP
See Also:
Constant Field Values
Constructor Detail

TinyMce

public TinyMce(ConfluenceSeleniumClient client,
               Editor editor)
Method Detail

getClient

public ConfluenceSeleniumClient getClient()

getLocatorForTags

public static java.lang.String getLocatorForTags(java.lang.String tagNames,
                                                 com.atlassian.selenium.Browser browser)
Returns a selenium locator or jQuery selector for the specified html tag in the TinyMCE editor. Depending on the browser, it will return the appropriate locator. This is required as different browsers have different implementations of the executing wywsiwyg commands such as bold, italic etc.


selectEditorFrame

public void selectEditorFrame()
Selects the TinyMCE iframe. You can then use Selenium assert methods normally. Use selectMainFrame() to reselect the main outer frame.


selectMainFrame

public void selectMainFrame()
Selects the main/top frame for Confluence.


selectFormat

public void selectFormat(TinyMce.Format format)

clickFormatMenuLink

public void clickFormatMenuLink()

getToolbarButtonId

public java.lang.String getToolbarButtonId(TinyMce.SimpleToolbarButton button)

isToolbarButtonEnabled

public boolean isToolbarButtonEnabled(TinyMce.SimpleToolbarButton button)

isToolbarButtonActive

public boolean isToolbarButtonActive(TinyMce.SimpleToolbarButton button)

clickToolbarButton

public void clickToolbarButton(TinyMce.SimpleToolbarButton button)

pressShortcut

public void pressShortcut(TinyMce.SimpleToolbarButton button)

pressShortcut

public void pressShortcut(TinyMce.ShortCut shortCut)

clickHorizontalRuler

public void clickHorizontalRuler()

clickInsertTable

public InsertTablePopup clickInsertTable()

clickInsertEmoticon

public EmoticonPickerPopup clickInsertEmoticon()

clickInsertCharacter

public InsertCharacterDialog clickInsertCharacter()

clickSelectedColor

public void clickSelectedColor()

getSelectedColor

public java.lang.String getSelectedColor()

getSelectedColorDisplayColor

public java.lang.String getSelectedColorDisplayColor()

selectTextColor

public void selectTextColor(java.lang.String rgbColor)

getFirstTextColor

public java.lang.String getFirstTextColor()
Gets the color of the first span with color in the style attribute.

Returns:
the hex color of the first span in the editor.

isRightAligned

public boolean isRightAligned(java.lang.String selector)
Checks that the given selector is right-aligned in the editor.

Parameters:
selector - The selector to check the style for.
Returns:
True if the selector has a text-align:right property.

isLeftAligned

public boolean isLeftAligned(java.lang.String selector)
Checks that the given selector is left-aligned in the editor.

Parameters:
selector - The selector to check the style for.
Returns:
True if the selector has a text-align:left property.

isAutocompleteDropdownPresent

public boolean isAutocompleteDropdownPresent()
Checks whether the autocomplete dropdown is present.

Returns:
True if it is present.

clickShortcutHelpDialog

public KeyboardShortcutHelpDialog clickShortcutHelpDialog()

waitForTableHeadingCellPresent

public void waitForTableHeadingCellPresent()

waitForTableCellPresent

public void waitForTableCellPresent()

getNumberOfRows

public int getNumberOfRows()

getFirstRowSelector

public java.lang.String getFirstRowSelector()

getLastRowSelector

public java.lang.String getLastRowSelector()

getRowSelector

public java.lang.String getRowSelector(int row)

getNumberOfCols

public int getNumberOfCols()

isTableHeaderRow

public boolean isTableHeaderRow(int row)

isTableNormalRow

public boolean isTableNormalRow(int row)

getTextInTableCell

public java.lang.String getTextInTableCell(int row,
                                           int col)

wasInsertedCorrectDirection

public java.lang.Boolean wasInsertedCorrectDirection(TinyMce.Position pos,
                                                     int selectedRow)

setContent

public void setContent(java.lang.String content)

setHtmlContent

public void setHtmlContent(java.lang.String html)
Used by tests rather than to replicate user behaviour. Sets the content of the RTE to be the HTML supplied.

Parameters:
html - valid HTML (not blank)

getContent

public java.lang.String getContent()
Returns the current content of the Editor as HTML.


getContent

public java.lang.String getContent(java.lang.String selector,
                                   boolean removeNewLines)
Returns the current content specified by the selector from the Editor as HTML.


getContentIncludingNode

public java.lang.String getContentIncludingNode(java.lang.String selector)
Returns the current content specified by the selector from the Editor as HTML, including the selector itself.


editorContentFocus

public void editorContentFocus()

type

public void type(java.lang.String content)
Only works for Firefox, and period doesn't work. http://jira.openqa.org/browse/SEL-521


typeWithFullKeyEvents

public void typeWithFullKeyEvents(java.lang.String content)
Only works for Firefox, and period doesn't work. http://jira.openqa.org/browse/SEL-521

See Also:
SeleniumClient.typeWithFullKeyEvents(String, String)

selectFirstElementWithSelector

public void selectFirstElementWithSelector(java.lang.String selector)
Select the first element matching the given selector.

Parameters:
selector - see tiny_mce_src.DOMUtils.select

selectElementWithSelectorAndIndex

public void selectElementWithSelectorAndIndex(java.lang.String selector,
                                              int elementIndex)
Select the nth element matching the given selector.

Parameters:
selector - see tiny_mce_src.DOMUtils.select
elementIndex - index of matched element to select, 0-indexed

getCurrentSelectionText

public java.lang.String getCurrentSelectionText()
Returns the text of the current editor selection.


putCursorAtStartOfElementWithSelectorAndIndex

public void putCursorAtStartOfElementWithSelectorAndIndex(java.lang.String selector,
                                                          int elementIndex)
Place the cursor at the start of the element matching the given selector and index. Seems to work in Firefox & IE, although the moxiecode docs indicate that the 'true' second parameter doesn't do anything in IE. If this method turns out to be consistent we could refactor putCursorAtStartOfFirstElementWithSelector(String) into it.

Parameters:
selector - see tiny_mce_src.DOMUtils.select
elementIndex - index of matched element to select, 0-indexed

putCursorAtStartOfFirstElementWithSelector

public void putCursorAtStartOfFirstElementWithSelector(java.lang.String selector)
Place the cursor at the start of the first element matching the given selector.

Parameters:
selector - see tiny_mce_src.DOMUtils.select

placeCursorAtStart

public void placeCursorAtStart(java.lang.String selector)
Positions the cursor at the start of the first matched element for the provided CSS selector.


placeCursor

public void placeCursor(java.lang.String selector,
                        int position)
Positions the cursor at the specified position in the first matched element for the provided CSS selector. Doesn't work for IE very well.


selectEmptyFirstParagraph

public void selectEmptyFirstParagraph()

selectFirstParagraph

public void selectFirstParagraph()

isMacroPropertyPanelPresent

public boolean isMacroPropertyPanelPresent()

selectMacro

public MacroPropertyPanel selectMacro(java.lang.String macroName,
                                      java.lang.Runnable waitFor)

selectMacro

public MacroPropertyPanel selectMacro(java.lang.String macroName)

isTablePresent

public boolean isTablePresent()

isRowHighlighted

public boolean isRowHighlighted()
Checks if the first row in the table is a heading row

Returns:
true iff the first row is a heading row

isRowHeading

public boolean isRowHeading(int row)
Checks if the nth row is a heading row

Parameters:
row - - the position of the row in the table (the first row == 1)
Returns:
true if the nth row is a heading row

isColumnHeading

public boolean isColumnHeading(int column)
Checks if the nth column is column row.

Parameters:
column - - the position of the column in the table (the first column == 1)
Returns:
true if the nth column is a heading column

isCellHighlighted

public boolean isCellHighlighted(int row,
                                 int column,
                                 java.lang.String colour)
Checks if the row and column is highlighted.

Parameters:
row - - the position of the row in the table (the first row == 1)
column - - the position of the column in the table (the first column == 1)
colour - - highlight colour
Returns:
true iff the nth row is highlighted

waitForMacroPresent

public void waitForMacroPresent(java.lang.String macroName)

isMacroPresent

public boolean isMacroPresent(java.lang.String macroName)
See Also:
isMacroPresent(String, String, String, String)

isMacroPresent

public boolean isMacroPresent(java.lang.String macroName,
                              java.lang.String parameters)
See Also:
isMacroPresent(String, String, String, String)

isMacroPresent

public boolean isMacroPresent(java.lang.String macroName,
                              java.lang.String parameters,
                              java.lang.String bodyText)
See Also:
isMacroPresent(String, String, String, String)

isMacroPresent

public boolean isMacroPresent(java.lang.String macroName,
                              java.lang.String parameters,
                              java.lang.String bodyText,
                              java.lang.String defaultParameter)
Returns true if the macro with given parameters and body text, is present in the editor.

Parameters:
macroName - name of the macro
parameters - String in the wiki markup format key=value|key=value with keys in alphabetical order.
bodyText - expected raw text of the macro body

isMacroPresent

public boolean isMacroPresent(Macro macro)
Returns true if a macro with given name is present in the editor.

Parameters:
macro - instance of Macro

getMacroBodyText

public java.lang.String getMacroBodyText(java.lang.String macroName)
Returns the body text of the macro. It assumes that there is one such macro on the page and that it is a body macro.

Parameters:
macroName - name of macro with body
Returns:
String of the macro body text

waitForSelectorPresentWithText

public void waitForSelectorPresentWithText(java.lang.String selector,
                                           java.lang.String bodyText)

waitForSelectorPresentWithText

public void waitForSelectorPresentWithText(java.lang.String selector,
                                           int index,
                                           java.lang.String bodyText)

getTextBeforeMacro

public java.lang.String getTextBeforeMacro(java.lang.String macroName)
Returns the text in the Paragraph element before the macro (or its wrapper).


getTextAfterMacro

public java.lang.String getTextAfterMacro(java.lang.String macroName)
Returns the text in the Paragraph element after the macro (or its wrapper).


isImagePresent

public boolean isImagePresent(Attachment attachment)
Returns true if the given attachment is present in the RTE.


isExternalImagePresent

public boolean isExternalImagePresent(java.lang.String image)
Returns true if the given attachment is present in the RTE.


pressBackspace

public void pressBackspace()
Types the "Backspace" key at the current cursor position.


pressEnter

public void pressEnter()
Types the "Enter" key at the current cursor position. Known to have problems in IE.


pressEscape

public void pressEscape()
Types the "Escape" key at the current cursor position.


pressDown

public void pressDown()
Types the "Down arrow" key at the current cursor position.


pressUp

public void pressUp()
Types the "Up arrow" key at the current cursor position.


dispatchClickEventForSelector

public void dispatchClickEventForSelector(java.lang.String selector)
Triggers ed.onClick.dispatch on TinyMCE

Parameters:
selector - jQuery selector for element to click, should only select one element

waitForSelectorPresent

public void waitForSelectorPresent(java.lang.String selector)
Wait for the given jQuery selector to be present in the TinyMCE editor.


getSelectorPresentScript

public java.lang.String getSelectorPresentScript(java.lang.String selector)
Returns a javascript function that checks for the presence of an element with given jquery selector in the TinyMCE editor.


isSelectorPresent

public boolean isSelectorPresent(java.lang.String selector)
Parameters:
selector - jquery selector to check for
Returns:
true if the given selector is present in the editor

waitForImage

public void waitForImage(Attachment image)
Wait for the specified image to load. Waits until an image has loaded that contains the given string in it's src attribute.

Parameters:
image - The image that should be present in the editor.

getSelectorCount

public int getSelectorCount(java.lang.String selector)
Returns the number of elements present in the editor specified by the given selector.

Parameters:
selector - jQuery selector

getExpressionValue

public java.lang.String getExpressionValue(java.lang.String expression)
Makes the TinyMCE doc available to the passed expression and evaluates it, returning the string result.

Parameters:
expression - a JavaScript expression, can assume "doc" is the TinyMCE document.
Returns:
String result of the expression

waitForSelectorCount

public void waitForSelectorCount(java.lang.String selector,
                                 int count)

getAttributeForSelector

public java.lang.String getAttributeForSelector(java.lang.String selector,
                                                java.lang.String attribute)
Returns the value of the given attribute for the given selector.


getCssAttributeForSelector

public java.lang.String getCssAttributeForSelector(java.lang.String selector,
                                                   java.lang.String attribute)
Returns the value of the given attribute for the given selector.


setContentForSelector

public void setContentForSelector(java.lang.String selector,
                                  java.lang.String text)
Sets the passed text in the RTE element matching the selector.


getSelectorScript

public java.lang.String getSelectorScript(java.lang.String selector)
Returns a javascript function that checks for the presence of an element with given jquery selector in the TinyMCE editor.


getBookmark

public TinyMce.Bookmark getBookmark()

openInsertMenu

public EditorInsertMenu openInsertMenu()

openMoreMenu

public EditorMoreMenu openMoreMenu()

scrollTopTo

public void scrollTopTo(int scrollTop)
Scroll the RTE vertically to a certain position.


clickOutsideEditor

public void clickOutsideEditor()
Used for clicking something outside of the TinyMCE editor that is (currently) known to not have any click-handler on it.


triggerAutocomplete

public EditorAutocomplete triggerAutocomplete(TinyMce.ShortCut shortCut)
Launches the autocomplete by pressing a shortcut key combination at the current cursor position.


toggleSourceMode

public void toggleSourceMode()

getImageSelector

public java.lang.String getImageSelector(boolean thumbnail)
Returns the TinyMce selector for images in the editor.

Parameters:
thumbnail - true, then the selector applies to image thumbnails, false it does not
Returns:
the selector for use in other TinyMce method calls accepting a selector.

copyAndPaste

public void copyAndPaste(java.lang.String selector)
Copies the content specified by the selector, and pastes it before the content.

Parameters:
selector -

pasteContent

public void pasteContent(java.lang.String html)
Pastes the content as though it came from the clipboard.

Parameters:
html -


Copyright © 2003-2014 Atlassian. All Rights Reserved.