com.atlassian.confluence.selenium.client
Class Editor

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

public class Editor
extends java.lang.Object


Nested Class Summary
static class Editor.EditorMode
           
 
Field Summary
static java.lang.String EDITOR_ID
           
static int EDITOR_TIMEOUT_MILLIS
           
 
Constructor Summary
Editor(ConfluenceSeleniumClient client, Suite suite)
           
 
Method Summary
 void addComment(Page page)
           
 void addComment(PageView pageView)
          Add a comment from a page view.
 void addErrorMessage(java.lang.String id, java.lang.String message, boolean showInAllModes)
          Adds the specified error message to the screen.
 PageView cancel()
           
 void clickSave()
          Click the save button but perform no waits or assertions.
 PageTemplateWizard clickSelectTemplate()
           
 void closeCalanderPickerByClickInEditor()
          Deprecated. since 5.5 write a Webdriver test instead and use CreateBlog#getDatePicker
 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()
           
 java.lang.String getContent()
           
 long getContentId()
           
 EditorPreview getEditorPreview()
           
 java.lang.String getFirstMatchingPreviewNodeText(java.lang.String selector)
           
 java.lang.String getHtmlSourceContent()
           
 Location getLocation()
           
 MacroBrowser getMacroBrowser()
          For use when opening the macro browser manually, e.g.
 java.util.Map<java.lang.String,java.lang.String> getMacroParameters(java.lang.String name)
          Retrieve a macro's parameters from the editor.
 java.lang.String getNormalisedContent()
          Returns a version of getContent() that should be the same in all browsers.
 java.lang.String getPreviewContent()
           
 java.lang.String getPreviewSelectorScript(java.lang.String selector)
           
 java.lang.String getPreviewTableCellText(int row, int column)
           
 TinyMce getTinyMce()
           
 java.lang.String getTitle()
          Gets the value in the editor Title field.
 long getToolbarPositionTop()
           
 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(java.lang.String name, java.util.Map<java.lang.String,java.lang.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 isPresent()
           
 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 logInAndCreateEditorTemplate(User user, Space space)
           
 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)
           
 java.lang.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.
 void saveDraft()
           
 PageView saveWithKeyboardShortcut()
           
 MovePageDialog saveWithLocation()
          Note that this is only available as a dark feature now.
 void selectFirstParagraph()
           
 void setContent(java.lang.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 setHtmlContent(java.lang.String htmlContent)
           
 void setHtmlSource(java.lang.String source)
           
 void setTitle(java.lang.String title)
           
 void setVersionComment(java.lang.String versionComment)
           
 EditorPreview switchToPreview()
           
 TinyMce switchToRichText()
           
 void swtichToSource()
           
 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 triggerDraftAutoSave()
          Triggers a draft by switching to preview mode.
 void viewConflict()
          Click the link to resolve a conflict between an existing draft and the current editor content.
 void waitForCalanderPickerClose()
          Deprecated. since 5.5 write a Webdriver test instead and use CreateBlog#getDatePicker
 void waitForCalendarPicker()
          Deprecated. since 5.5 write a Webdriver test instead and use CreateBlog#getDatePicker
 void waitForDraftAutoSavedMessage()
           
 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 java.lang.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,
              Suite suite)
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)

logInAndCreateEditorTemplate

public TinyMce logInAndCreateEditorTemplate(User user,
                                            Space space)

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)

isPresent

public boolean isPresent()
Returns:
true if the editor is actually present in the page.

getHtmlSourceContent

public java.lang.String getHtmlSourceContent()

getTitle

public java.lang.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 java.lang.String getPreviewContent()

getPreviewTableCellText

public java.lang.String getPreviewTableCellText(int row,
                                                int column)

getFirstMatchingPreviewNodeText

public java.lang.String getFirstMatchingPreviewNodeText(java.lang.String selector)

getPreviewSelectorScript

public java.lang.String getPreviewSelectorScript(java.lang.String selector)

setHtmlContent

public void setHtmlContent(java.lang.String htmlContent)

setContent

public void setContent(java.lang.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(java.lang.String source)

setVersionComment

public void setVersionComment(java.lang.String versionComment)

getContent

public java.lang.String getContent()

getNormalisedContent

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

selectFirstParagraph

public void selectFirstParagraph()

switchToRichText

public TinyMce switchToRichText()

switchToPreview

public EditorPreview switchToPreview()

getEditorPreview

public EditorPreview getEditorPreview()

swtichToSource

public void swtichToSource()

triggerDraftAutoSave

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


waitForDraftAutoSavedMessage

public void waitForDraftAutoSavedMessage()

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.


clickSave

public void clickSave()
Click the save button but perform no waits or assertions. This provides flexibility in testing.


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 java.lang.String saveAndExpectAlert()
Clicks save but expects an alert mesage without leaving the page.

Returns:
The alerted message

cancel

public PageView 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(java.lang.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.


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

@Deprecated
public void waitForCalendarPicker()
Deprecated. since 5.5 write a Webdriver test instead and use CreateBlog#getDatePicker


closeCalanderPickerByClickInEditor

@Deprecated
public void closeCalanderPickerByClickInEditor()
Deprecated. since 5.5 write a Webdriver test instead and use CreateBlog#getDatePicker

Has the unfortunate side effect of losing your cursor position, blame tinymce.


waitForCalanderPickerClose

@Deprecated
public void waitForCalanderPickerClose()
Deprecated. since 5.5 write a Webdriver test instead and use CreateBlog#getDatePicker


waitForHeartbeatMessage

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


isHeartbeatMessageVisible

public boolean isHeartbeatMessageVisible()

clickSelectTemplate

public PageTemplateWizard clickSelectTemplate()

getMacroParameters

public java.util.Map<java.lang.String,java.lang.String> getMacroParameters(java.lang.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(java.lang.String name,
                              java.util.Map<java.lang.String,java.lang.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(java.lang.String id,
                            java.lang.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.

saveDraft

public void saveDraft()


Copyright © 2003-2014 Atlassian. All Rights Reserved.