com.atlassian.confluence.selenium.client
Class TinyMce

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

public class TinyMce
extends 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 String TINYMCE_LOCATOR
           
static 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(String selector)
          Copies the content specified by the selector, and pastes it before the content.
 void dispatchClickEventForSelector(String selector)
          Triggers ed.onClick.dispatch on TinyMCE
 String getAttributeForSelector(String selector, String attribute)
          Returns the value of the given attribute for the given selector.
 TinyMce.Bookmark getBookmark()
           
 ConfluenceSeleniumClient getClient()
           
 String getContent()
          Returns the current content of the Editor as HTML.
 String getContent(String selector, boolean removeNewLines)
          Returns the current content specified by the selector from the Editor as HTML.
 String getContentIncludingNode(String selector)
          Returns the current content specified by the selector from the Editor as HTML, including the selector itself.
 String getCssAttributeForSelector(String selector, String attribute)
          Returns the value of the given attribute for the given selector.
 String getCurrentSelectionText()
          Returns the text of the current editor selection.
 String getExpressionValue(String expression)
          Makes the TinyMCE doc available to the passed expression and evaluates it, returning the string result.
 String getFirstRowSelector()
           
 String getFirstTextColor()
          Gets the color of the first span with color in the style attribute.
 String getImageSelector(boolean thumbnail)
          Returns the TinyMce selector for images in the editor.
 String getLastRowSelector()
           
static String getLocatorForTags(String tagNames, com.atlassian.selenium.Browser browser)
          Returns a selenium locator or jQuery selector for the specified html tag in the TinyMCE editor.
 String getMacroBodyText(String macroName)
          Returns the body text of the macro.
 int getNumberOfCols()
           
 int getNumberOfRows()
           
 String getRowSelector(int row)
           
 String getSelectedColor()
           
 String getSelectedColorDisplayColor()
           
 int getSelectorCount(String selector)
          Returns the number of elements present in the editor specified by the given selector.
 String getSelectorPresentScript(String selector)
          Returns a javascript function that checks for the presence of an element with given jquery selector in the TinyMCE editor.
 String getSelectorScript(String selector)
          Returns a javascript function that checks for the presence of an element with given jquery selector in the TinyMCE editor.
 String getTextAfterMacro(String macroName)
          Returns the text in the Paragraph element after the macro (or its wrapper).
 String getTextBeforeMacro(String macroName)
          Returns the text in the Paragraph element before the macro (or its wrapper).
 String getTextInTableCell(int row, int col)
           
 String getToolbarButtonId(TinyMce.SimpleToolbarButton button)
           
 boolean isAutocompleteDropdownPresent()
          Checks whether the autocomplete dropdown is present.
 boolean isCellHighlighted(int row, int column)
          Checks if the row and column is highlighted.
 boolean isColumnHighlighted(int column)
          Checks if the nth column is completely highlighted.
 boolean isImagePresent(Attachment attachment)
          Returns true if the given attachment is present in the RTE.
 boolean isLeftAligned(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(String macroName)
           
 boolean isMacroPresent(String macroName, String parameters)
           
 boolean isMacroPresent(String macroName, String parameters, String bodyText)
           
 boolean isMacroPresent(String macroName, String parameters, String bodyText, String defaultParameter)
          Returns true if the macro with given parameters and body text, is present in the editor.
 boolean isMacroPropertyPanelPresent()
           
 boolean isRightAligned(String selector)
          Checks that the given selector is right-aligned in the editor.
 boolean isRowHighlighted()
          Checks if the first row in the table is completely highlighted
 boolean isRowHighlighted(int row)
          Checks if the nth row is completely highlighted
 boolean isSelectorPresent(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(String html)
          Pastes the content as though it came from the clipboard.
 void placeCursor(String selector, int position)
          Positions the cursor at the specified position in the first matched element for the provided CSS selector.
 void placeCursorAtStart(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(String selector, int elementIndex)
          Place the cursor at the start of the element matching the given selector and index.
 void putCursorAtStartOfFirstElementWithSelector(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(String selector, int elementIndex)
          Select the nth element matching the given selector.
 void selectEmptyFirstParagraph()
           
 void selectFirstElementWithSelector(String selector)
          Select the first element matching the given selector.
 void selectFirstParagraph()
           
 void selectFormat(TinyMce.Format format)
           
 MacroPropertyPanel selectMacro(String macroName)
           
 MacroPropertyPanel selectMacro(String macroName, Runnable waitFor)
           
 void selectMainFrame()
          Selects the main/top frame for Confluence.
 void selectTextColor(String rgbColor)
           
 void setContent(String content)
           
 void setContentForSelector(String selector, String text)
          Sets the passed text in the RTE element matching the selector.
 void setHtmlContent(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(String content)
          Only works for Firefox, and period doesn't work.
 void typeWithFullKeyEvents(String content)
          Only works for Firefox, and period doesn't work.
 void waitForImage(String str)
          Wait for the specified image to load.
 void waitForMacroPresent(String macroName)
           
 void waitForSelectorCount(String selector, int count)
           
 void waitForSelectorPresent(String selector)
          Wait for the given jQuery selector to be present in the TinyMCE editor.
 void waitForSelectorPresentWithText(String selector, int index, String bodyText)
           
 void waitForSelectorPresentWithText(String selector, String bodyText)
           
 void waitForTableCellPresent()
           
 void waitForTableHeadingCellPresent()
           
 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 String TINYMCE_LOCATOR
See Also:
Constant Field Values

TOOLBAR_LOCATOR

public static final 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 String getLocatorForTags(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 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 String getSelectedColor()

getSelectedColorDisplayColor

public String getSelectedColorDisplayColor()

selectTextColor

public void selectTextColor(String rgbColor)

getFirstTextColor

public 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(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(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 String getFirstRowSelector()

getLastRowSelector

public String getLastRowSelector()

getRowSelector

public String getRowSelector(int row)

getNumberOfCols

public int getNumberOfCols()

isTableHeaderRow

public boolean isTableHeaderRow(int row)

isTableNormalRow

public boolean isTableNormalRow(int row)

getTextInTableCell

public String getTextInTableCell(int row,
                                 int col)

wasInsertedCorrectDirection

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

setContent

public void setContent(String content)

setHtmlContent

public void setHtmlContent(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 String getContent()
Returns the current content of the Editor as HTML.


getContent

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


getContentIncludingNode

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


type

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


typeWithFullKeyEvents

public void typeWithFullKeyEvents(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(String selector)
Select the first element matching the given selector.

Parameters:
selector - see tiny_mce_src.DOMUtils.select

selectElementWithSelectorAndIndex

public void selectElementWithSelectorAndIndex(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 String getCurrentSelectionText()
Returns the text of the current editor selection.


putCursorAtStartOfElementWithSelectorAndIndex

public void putCursorAtStartOfElementWithSelectorAndIndex(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(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(String selector)
Positions the cursor at the start of the first matched element for the provided CSS selector.


placeCursor

public void placeCursor(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(String macroName,
                                      Runnable waitFor)

selectMacro

public MacroPropertyPanel selectMacro(String macroName)

isTablePresent

public boolean isTablePresent()

isRowHighlighted

public boolean isRowHighlighted()
Checks if the first row in the table is completely highlighted

Returns:
true iff the first row is highlighted

isRowHighlighted

public boolean isRowHighlighted(int row)
Checks if the nth row is completely highlighted

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

isColumnHighlighted

public boolean isColumnHighlighted(int column)
Checks if the nth column is completely highlighted.

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

isCellHighlighted

public boolean isCellHighlighted(int row,
                                 int column)
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)
Returns:
true iff the nth row is highlighted

waitForMacroPresent

public void waitForMacroPresent(String macroName)

isMacroPresent

public boolean isMacroPresent(String macroName)
See Also:
isMacroPresent(String, String, String, String)

isMacroPresent

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

isMacroPresent

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

isMacroPresent

public boolean isMacroPresent(String macroName,
                              String parameters,
                              String bodyText,
                              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 String getMacroBodyText(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(String selector,
                                           String bodyText)

waitForSelectorPresentWithText

public void waitForSelectorPresentWithText(String selector,
                                           int index,
                                           String bodyText)

getTextBeforeMacro

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


getTextAfterMacro

public String getTextAfterMacro(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.


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(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(String selector)
Wait for the given jQuery selector to be present in the TinyMCE editor.


getSelectorPresentScript

public String getSelectorPresentScript(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(String selector)
Parameters:
selector - jquery selector to check for
Returns:
true if the given selector is present in the editor

waitForImage

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

Parameters:
str - The string that should be contained in the image's src attribute

getSelectorCount

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

Parameters:
selector - jQuery selector

getExpressionValue

public String getExpressionValue(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(String selector,
                                 int count)

getAttributeForSelector

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


getCssAttributeForSelector

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


setContentForSelector

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


getSelectorScript

public String getSelectorScript(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 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(String selector)
Copies the content specified by the selector, and pastes it before the content.

Parameters:
selector -

pasteContent

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

Parameters:
html -


Copyright © 2003-2011 Atlassian. All Rights Reserved.