com.atlassian.confluence.selenium.client
Class Editor

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

public class Editor
extends Object


Nested Class Summary
static class Editor.EditorMode
           
 
Field Summary
static String EDITOR_ID
           
static int EDITOR_TIMEOUT_MILLIS
           
 
Constructor Summary
Editor(ConfluenceSeleniumClient client, Confluence confluence)
           
 
Method Summary
 void addComment(Page page)
           
 void addComment(PageView pageView)
          Add a comment from a page view.
 void addErrorMessage(String id, String message, boolean showInAllModes)
          Adds the specified error message to the screen.
 void cancel()
           
 PageTemplateWizard clickSelectTemplate()
           
 void closeCalanderPickerByClickInEditor()
          Has the unfortunate side effect of losing your cursor position, blame tinymce.
 void closeDraftMessage()
           
 void createBlogPost(Space space)
           
 void createPage(Space space)
           
 PageTemplateWizard createPageFromTemplate(Space space)
           
 PageTemplateWizard createPageFromTemplate(Space space, long parentPageId)
           
 void discardDraft()
           
 TinyMce edit(ContentEntity contentEntity)
           
 long getAttachmentSourceContentId()
           
 String getContent()
           
 long getContentId()
           
 EditorPreview getEditorPreview()
           
 String getFirstMatchingPreviewNodeText(String selector)
           
 String getHtmlSourceContent()
           
 Location getLocation()
           
 MacroBrowser getMacroBrowser()
          For use when opening the macro browser manually, e.g.
 Map<String,String> getMacroParameters(String name)
          Retrieve a macro's parameters from the editor.
 String getNormalisedContent()
          Returns a version of getContent() that should be the same in all browsers.
 String getPreviewContent()
           
 String getPreviewSelectorScript(String selector)
           
 String getPreviewTableCellText(int row, int column)
           
 String getRichTextContent()
          Deprecated. since 4.0 Use getContent() instead
 TinyMce getTinyMce()
           
 String getTitle()
          Gets the value in the editor Title field.
 long getToolbarPositionTop()
           
 String getWikiMarkupContent()
          Deprecated.  
 boolean hasContentChanged()
          Returns true if Confluence considers the editor content to have changed.
 InsertImageDialog insertImage()
          Opens the image dialog if in RTE mode.
 void insertImage(Attachment attachment)
           
 boolean isBlogPost()
           
 boolean isCreatePage()
           
 boolean isHeartbeatMessageVisible()
           
 boolean isMacroPresent(String name, Map<String,String> parameters)
          Encapsulate the editor representation of macros in a single place for testing.
 boolean isPermisionsEditorPresent()
           
 boolean isPermissionsSet()
          Returns true if permissions have been set in the editor.
 boolean isRichTextMode()
           
 boolean isSourceMode()
           
 boolean isTitleEditable()
           
 TinyMce logInAndAddComment(User user, BlogPost blogpost)
           
 TinyMce logInAndAddComment(User user, Page page)
           
 TinyMce logInAndCopyPage(User user, Page page)
           
 TinyMce logInAndCreateBlogPost(User user, Space space)
           
 TinyMce logInAndCreateChildPage(User user, Space space, long parentPageId)
           
 TinyMce logInAndCreatePage(User user, Space space)
           
 TinyMce logInAndEdit(User user, ContentEntity contentEntity)
           
 TinyMce logInAndEditInRTE(User user, ContentEntity contentEntity)
          Logs the given user in, edits the given content and switches to the RTE.
 void merge()
          Click the link to merge an existing draft with the current editor content.
 void openCalenderPicker()
           
 LinkBrowser openLinkBrowser()
           
 MacroBrowser openMacroBrowser()
           
 MacroBrowser openMacroBrowserViaShortcut()
           
 PagePermissionsEditor openPermissionsEditor()
           
 void overwriteDraft()
          Click the link to overwrite a conflicting draft with the current editor content.
 void replyToComment(Comment comment)
          Opens the reply page for the given comment
 void resumeDraft()
           
 PageView save()
           
 PageView save(MovePageDialog dialog)
           
 String saveAndExpectAlert()
          Clicks save but expects an alert mesage without leaving the page.
 Editor saveAndExpectToFail()
          Saves the page and expects to return to the editor.
 PageView saveWithKeyboardShortcut()
           
 MovePageDialog saveWithLocation()
          Note that this is only available as a dark feature now.
 void selectFirstParagraph()
           
 void setContent(String content)
          Note: Be careful with \n characters as they behave differently in IE and FF at the moment.
 void setCursorPosition(int pos)
          Sets the cursor position in the markup editor.
 void setCursorPositionToEnd()
          Puts the cursor at the end of the Wiki Markup editor.
 void setHtmlContent(String htmlContent)
           
 void setHtmlSource(String source)
           
 void setTitle(String title)
           
 void setVersionComment(String versionComment)
           
 void setWikiMarkupContent(String markup)
          Deprecated. Try setHtmlContent(java.lang.String) for injecting content into the Editor without typing.
 void switchToMarkup()
          Deprecated. No more markup editor.
 EditorPreview switchToPreview()
           
 TinyMce switchToRichText()
           
 void swtichToSource()
           
 void triggerDraft()
          Triggers a draft by switching to preview mode.
 void triggerDraftAndCheckNoUserDrafts(Page page)
          Leaves a unmodified page and checks that the draft screen does NOT contain a draft with the title of the given page.
 void triggerDraftAndCheckUserDrafts()
           
 void triggerDraftAndCheckUserDrafts(BlogPost blogpost)
           
 void triggerDraftAndCheckUserDrafts(Page page)
          Triggers a draft to be saved and then checks that the draft screen contains a draft with the title of the given page.
 void triggerDraftAndEdit(Page page)
          Triggers a draft to be saved.
 void viewConflict()
          Click the link to resolve a conflict between an existing draft and the current editor content.
 void waitForCalanderPickerClose()
           
 void waitForCalendarPicker()
           
 void waitForDraftSavedMessage()
           
 void waitForEditorPageLoad()
          Waits for the page to load with the configured editor page load timeout.
 void waitForHeartbeatMessage()
          Waits for the heartbeat message container to appear.
 void waitForPreviewToLoad()
          Wait until the preview is loaded
 void waitUntilEditorIsVisible()
          Wait until the RTE is visible after switching back from the preview
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDITOR_ID

public static final String EDITOR_ID
See Also:
Constant Field Values

EDITOR_TIMEOUT_MILLIS

public static final int EDITOR_TIMEOUT_MILLIS
Constructor Detail

Editor

public Editor(ConfluenceSeleniumClient client,
              Confluence confluence)
Method Detail

waitForEditorPageLoad

public void waitForEditorPageLoad()
Waits for the page to load with the configured editor page load timeout. Loading editor pages is quite slow, so it should be higher than the other configured timeouts.


logInAndCopyPage

public TinyMce logInAndCopyPage(User user,
                                Page page)

logInAndCreatePage

public TinyMce logInAndCreatePage(User user,
                                  Space space)

logInAndCreateChildPage

public TinyMce logInAndCreateChildPage(User user,
                                       Space space,
                                       long parentPageId)

logInAndCreateBlogPost

public TinyMce logInAndCreateBlogPost(User user,
                                      Space space)

logInAndEdit

public TinyMce logInAndEdit(User user,
                            ContentEntity contentEntity)

logInAndAddComment

public TinyMce logInAndAddComment(User user,
                                  Page page)

logInAndAddComment

public TinyMce logInAndAddComment(User user,
                                  BlogPost blogpost)

logInAndEditInRTE

public TinyMce logInAndEditInRTE(User user,
                                 ContentEntity contentEntity)
Logs the given user in, edits the given content and switches to the RTE.

Returns:
the TinyMce reference

edit

public TinyMce edit(ContentEntity contentEntity)

addComment

public void addComment(Page page)

addComment

public void addComment(PageView pageView)
Add a comment from a page view. This method actually clicks on the load rte link for the comment rather than going to the add comment url directly.


replyToComment

public void replyToComment(Comment comment)
Opens the reply page for the given comment

Parameters:
comment - The comment to reply to. It must have an id and page id set.

createPage

public void createPage(Space space)

createPageFromTemplate

public PageTemplateWizard createPageFromTemplate(Space space)

createPageFromTemplate

public PageTemplateWizard createPageFromTemplate(Space space,
                                                 long parentPageId)

createBlogPost

public void createBlogPost(Space space)

getRichTextContent

public String getRichTextContent()
Deprecated. since 4.0 Use getContent() instead


getWikiMarkupContent

public String getWikiMarkupContent()
Deprecated. 


getHtmlSourceContent

public String getHtmlSourceContent()

getTitle

public String getTitle()
Gets the value in the editor Title field. If the field is showing the default greyed-text title an empty string will be returned.


getPreviewContent

public String getPreviewContent()

getPreviewTableCellText

public String getPreviewTableCellText(int row,
                                      int column)

getFirstMatchingPreviewNodeText

public String getFirstMatchingPreviewNodeText(String selector)

getPreviewSelectorScript

public String getPreviewSelectorScript(String selector)

setWikiMarkupContent

public void setWikiMarkupContent(String markup)
Deprecated. Try setHtmlContent(java.lang.String) for injecting content into the Editor without typing.


setHtmlContent

public void setHtmlContent(String htmlContent)

setContent

public void setContent(String content)
Note: Be careful with \n characters as they behave differently in IE and FF at the moment. (IE->p, FF->br)


setHtmlSource

public void setHtmlSource(String source)

setVersionComment

public void setVersionComment(String versionComment)

getContent

public String getContent()

getNormalisedContent

public String getNormalisedContent()
Returns a version of getContent() that should be the same in all browsers. The content is:

selectFirstParagraph

public void selectFirstParagraph()

switchToMarkup

public void switchToMarkup()
Deprecated. No more markup editor.


switchToRichText

public TinyMce switchToRichText()

switchToPreview

public EditorPreview switchToPreview()

getEditorPreview

public EditorPreview getEditorPreview()

swtichToSource

public void swtichToSource()

triggerDraft

public void triggerDraft()
Triggers a draft by switching to preview mode.


waitForDraftSavedMessage

public void waitForDraftSavedMessage()

closeDraftMessage

public void closeDraftMessage()

triggerDraftAndCheckUserDrafts

public void triggerDraftAndCheckUserDrafts(Page page)
Triggers a draft to be saved and then checks that the draft screen contains a draft with the title of the given page.


triggerDraftAndCheckUserDrafts

public void triggerDraftAndCheckUserDrafts(BlogPost blogpost)

triggerDraftAndCheckUserDrafts

public void triggerDraftAndCheckUserDrafts()

triggerDraftAndCheckNoUserDrafts

public void triggerDraftAndCheckNoUserDrafts(Page page)
Leaves a unmodified page and checks that the draft screen does NOT contain a draft with the title of the given page.


triggerDraftAndEdit

public void triggerDraftAndEdit(Page page)
Triggers a draft to be saved. It checks that the draft screen contains a draft with the title of the given page and then returns to the edit page screen.


save

public PageView save()

save

public PageView save(MovePageDialog dialog)

saveWithKeyboardShortcut

public PageView saveWithKeyboardShortcut()

saveAndExpectToFail

public Editor saveAndExpectToFail()
Saves the page and expects to return to the editor. This is different from save() in that uses the editor timeout instead of the normal page view timeout and also fails if there is no editor on the page that shows after save.

Returns:
A reference to this object

saveAndExpectAlert

public String saveAndExpectAlert()
Clicks save but expects an alert mesage without leaving the page.

Returns:
The alerted message

cancel

public void cancel()

resumeDraft

public void resumeDraft()

discardDraft

public void discardDraft()

openPermissionsEditor

public PagePermissionsEditor openPermissionsEditor()

isPermissionsSet

public boolean isPermissionsSet()
Returns true if permissions have been set in the editor. This method checks for the permissions button label and ensures that at least one of hidden input permission fields have been set.

Returns:
true if permissions have been set in the editor

isPermisionsEditorPresent

public boolean isPermisionsEditorPresent()

setTitle

public void setTitle(String title)

isTitleEditable

public boolean isTitleEditable()

merge

public void merge()
Click the link to merge an existing draft with the current editor content.


viewConflict

public void viewConflict()
Click the link to resolve a conflict between an existing draft and the current editor content.


overwriteDraft

public void overwriteDraft()
Click the link to overwrite a conflicting draft with the current editor content.


setCursorPosition

public void setCursorPosition(int pos)
Sets the cursor position in the markup editor.


setCursorPositionToEnd

public void setCursorPositionToEnd()
Puts the cursor at the end of the Wiki Markup editor.


hasContentChanged

public boolean hasContentChanged()
Returns true if Confluence considers the editor content to have changed. Checks RTE and Wiki markup.


getTinyMce

public TinyMce getTinyMce()

isRichTextMode

public boolean isRichTextMode()

isSourceMode

public boolean isSourceMode()

saveWithLocation

public MovePageDialog saveWithLocation()
Note that this is only available as a dark feature now.


openMacroBrowserViaShortcut

public MacroBrowser openMacroBrowserViaShortcut()

openMacroBrowser

public MacroBrowser openMacroBrowser()

openLinkBrowser

public LinkBrowser openLinkBrowser()

getMacroBrowser

public MacroBrowser getMacroBrowser()
For use when opening the macro browser manually, e.g. via a context menu selection

Returns:
the macro browser.

waitForPreviewToLoad

public void waitForPreviewToLoad()
Wait until the preview is loaded


waitUntilEditorIsVisible

public void waitUntilEditorIsVisible()
Wait until the RTE is visible after switching back from the preview


insertImage

public InsertImageDialog insertImage()
Opens the image dialog if in RTE mode.


insertImage

public void insertImage(Attachment attachment)

getContentId

public long getContentId()

getAttachmentSourceContentId

public long getAttachmentSourceContentId()

isCreatePage

public boolean isCreatePage()

isBlogPost

public boolean isBlogPost()

getLocation

public Location getLocation()

getToolbarPositionTop

public long getToolbarPositionTop()

openCalenderPicker

public void openCalenderPicker()

waitForCalendarPicker

public void waitForCalendarPicker()

closeCalanderPickerByClickInEditor

public void closeCalanderPickerByClickInEditor()
Has the unfortunate side effect of losing your cursor position, blame tinymce.


waitForCalanderPickerClose

public void waitForCalanderPickerClose()

waitForHeartbeatMessage

public void waitForHeartbeatMessage()
Waits for the heartbeat message container to appear.


isHeartbeatMessageVisible

public boolean isHeartbeatMessageVisible()

clickSelectTemplate

public PageTemplateWizard clickSelectTemplate()

getMacroParameters

public Map<String,String> getMacroParameters(String name)
Retrieve a macro's parameters from the editor.

Parameters:
name - the name of the macro to be checked for
Returns:
the hashmap of the params of the macro, or an empty hashmap if the macro doesn't exist.
Throws:
com.thoughtworks.selenium.SeleniumException - if the macro doesn't exist.

isMacroPresent

public boolean isMacroPresent(String name,
                              Map<String,String> parameters)
Encapsulate the editor representation of macros in a single place for testing.

Parameters:
name - the name of the macro to be checked for
parameters - the parameters to be checked for or null if there are none.
Returns:
true if the content of the editor contains the macro as specified.

addErrorMessage

public void addErrorMessage(String id,
                            String message,
                            boolean showInAllModes)
Adds the specified error message to the screen.

Parameters:
id - the element id for the error to be added
message - the message to display
showInAllModes - true will show the error in both editor and preview modes, false only in editor mode.


Copyright © 2003-2011 Atlassian. All Rights Reserved.