com.atlassian.confluence.selenium.client
Class ConfluenceSeleniumClient

java.lang.Object
  extended by com.thoughtworks.selenium.DefaultSelenium
      extended by com.atlassian.selenium.SingleBrowserSeleniumClient
          extended by com.atlassian.confluence.selenium.client.ConfluenceSeleniumClient
All Implemented Interfaces:
com.atlassian.selenium.SeleniumClient, com.atlassian.selenium.visualcomparison.VisualComparableClient, com.thoughtworks.selenium.Selenium

public class ConfluenceSeleniumClient
extends com.atlassian.selenium.SingleBrowserSeleniumClient

Extends the Atlassian Selenium client to provide Confluence specific methods.


Field Summary
static String DOWN_KEY
           
static String UP_KEY
           
static String WIKI_CONTENT_XPATH
           
 
Fields inherited from class com.atlassian.selenium.SingleBrowserSeleniumClient
ACTION_WAIT, PAGE_LOAD_WAIT
 
Fields inherited from class com.thoughtworks.selenium.DefaultSelenium
commandProcessor
 
Method Summary
 void check(String name, String value)
          Checks a checkbox given a name and value.
 void cleanUp()
          Resets the selenium client to a default state so that we can not slow down the tests run accidentally anymore.
 void click(String locator, boolean waitForPageToLoad)
           
 void click(String locator, long timeoutMillis)
           
 void clickLinkWithTextInWikiContent(String text, boolean waitForPageToLoad)
          Clicks a link in the wiki content with the exact text given.
 String getBaseUrl()
           
 com.atlassian.selenium.Browser getBrowser()
           
 double getBrowserVersion()
           
 String getContextPath()
          Context path, including initial slash, eg "/confluence".
 String getEval(String javascript)
          Runs the provided Javascript statement in the context of the test page, not the Selenium tester like DefaultSelenium.getEval(String) does.
 boolean getEvalAsBoolean(String javascript)
           
 int getEvalAsInteger(String javascript)
           
 String getEvalFunction(String... functionLines)
          Varargs version of getEvalFunction(String) which joins together its arguments with newlines.
 String getEvalFunction(String function)
          Runs the provided Javascript function in the context of the test page.
 List<String> getEvalListFunction(String... functionLines)
          Version of getEvalFunction(String...) which executes a JS function which returns a list, joins the result on the client side using commas, then splits it back into a list to return.
static ConfluenceSeleniumClient getInstance()
           
 int getJQueryElementSelectorHeight(String selector)
          Gets the height of the supplied jQuery selector.
 String getMetadata(String key)
           
 boolean getMetadataBoolean(String key)
           
 long getMetadataLong(String key)
           
 boolean hasSelectorWithText(String selector, String text)
          Returns true if the given JQuery selector returns at least one result containing the supplied text.
 boolean isIE6Mode()
           
 boolean isJQueryElementSelectorPresent(String selector)
          Returns true if the given JQuery selector returns at least one result.
 void keyPressOnly(String locator, String key)
           
 void open(String url, long timeoutMillis)
          Overridden to append the context path in front of the url.
 void openAbsoluteURL(String url)
           
 void openAbsoluteURL(String url, long timeoutMillis)
           
 void pressBackspace(String elementLocator)
          Simulates pressing the backspace key in the element.
 void pressCtrlAltAndKey(String locator, String keySequence)
          Presses the control and alt keys, followed by the key(s) passed in
 void pressCtrlAndKey(String locator, String keySequence)
          Presses the control key, followed by the key(s) passed in.
 void pressCtrlAndKeyDownOnly(String locator, String keySequence)
          Use this method for key presses that will load a new page.
 void pressCtrlShiftAndKey(String locator, String keySequence)
          Presses the control+shift keys, followed by the key(s) passed in.
 void pressEnter(String elementLocator, boolean waitForPageToLoad)
          Simulates pressing the enter key in the element.
 void pressEscape(String elementLocator)
          Simulates pressing the Esc key in the element.
 void pressShiftAndKey(String locator, String keySequence)
           
 void pressTab(String elementLocator)
          Simulates pressing the tab key in the element.
 void selectTopFrame()
           
 void setScriptsFinishedPluginExpected(boolean expected)
           
 void submit(String form, boolean waitForPageToLoad)
           
 void submit(String form, boolean waitForPageToLoad, boolean onlyFireEvent)
           
 void submit(String form, long timeoutMillis)
           
 String toHexColor(String colorText)
          Converts style color "rbg(1, 2, 3)", or "#010203" into a hex color "010203".
 void typeInElementWithId(String elementId, String text)
           
 void typeWithLastCharFullKeyEvents(String locator, String text)
          Types text in the field specified by the locator.
 void waitForCondition(String javascript, String timeoutMillis)
          Runs the provided Javascript statement in the context of the test page, not the Selenium tester like DefaultSelenium.waitForCondition(String, String) does.
 void waitForFunction(String javascript)
           
 void waitForFunction(String javascript, String timeoutMillis)
          Runs the provided Javascript function in the context of the test page.
 void waitForJQueryElementSelector(String selector)
          Blocks until an element is found with the specified jQuery selector (or until the action timeout is reached).
 void waitForJQueryElementSelector(String selector, long timeoutMillis)
          Blocks until an element is found with the specified jQuery selector (or until the given timeout is reached).
 void waitForJQueryElementSelectorCount(String selector, int count)
          Blocks until a certain number of elements are found with the specified jQuery selector (or until the action timeout is reached).
 void waitForJqueryEventTriggered(String eventName, String selector)
          Will wait for a specfic event to be triggered.
 void waitForNoJQueryElementSelector(String selector)
           
 void waitForPageToLoad(long timeoutMillis)
           
 void waitForPageToLoad(String timeout)
          Override to make sure all Javascript has finished loading before returning.
 void waitForScriptsToLoad()
           
 void waitUntilFocused(String elementId)
          Waits until the element with the supplied id has cursor focus or until the default timeout expires.
 void waitUntilHiddenById(String elementId)
          Waits until the element with the supplied id is hidden or until the default timeout expires.
 void waitUntilRemoved(String selector)
          Waits until the elements matched by the supplied selector are removed from the DOM.
 void waitUntilVisible(String selector)
          Waits until the element(s) matched by the supplied selector is visible or until the default timeout expires.
 void waitUntilVisibleById(String elementId)
          Waits until the element with the supplied id is visible or until the default timeout expires.
 
Methods inherited from class com.atlassian.selenium.SingleBrowserSeleniumClient
captureEntirePageScreenshot, clickAndWaitForAjaxWithJquery, clickAndWaitForAjaxWithJquery, clickButton, clickButtonAndWaitForAjaxWithJquery, clickButtonWithName, clickButtonWithNameAndWaitForAjaxWithJquery, clickElementWithClass, clickElementWithClassAndWaitForAjaxWithJquery, clickElementWithCss, clickElementWithCssAndWaitForAjaxWithJquery, clickElementWithTitle, clickElementWithTitleAndWaitForAjaxWithJquery, clickElementWithXpath, clickElementWithXpathAndWaitForAjaxWithJquery, clickLinkWithText, evaluate, generateKeyEvent, hasJquery, keyPress, open, openNoWait, refreshAndWait, selectOption, selectOptionAndWaitForAjaxWithJquery, seleniumKeyPress, simulateKeyPressForCharacter, simulateKeyPressForCharacter, simulateKeyPressForSpecialKey, simulateKeyPressForSpecialKey, start, toggleToCharacterCode, toggleToKeyCode, typeInElementWithCss, typeInElementWithName, typeWithFullKeyEvents, typeWithFullKeyEvents, waitForAjaxWithJquery, waitForAjaxWithJquery, waitForCondition, waitForCondition, waitForJQuery, waitForPageToLoad
 
Methods inherited from class com.thoughtworks.selenium.DefaultSelenium
addCustomRequestHeader, addLocationStrategy, addScript, addSelection, allowNativeXpath, altKeyDown, altKeyUp, answerOnNextPrompt, assignId, attachFile, captureEntirePageScreenshot, captureEntirePageScreenshotToString, captureNetworkTraffic, captureScreenshot, captureScreenshotToString, check, chooseCancelOnNextConfirmation, chooseOkOnNextConfirmation, click, clickAt, close, contextMenu, contextMenuAt, controlKeyDown, controlKeyUp, createCookie, deleteAllVisibleCookies, deleteCookie, deselectPopUp, doubleClick, doubleClickAt, dragAndDrop, dragAndDropToObject, dragdrop, fireEvent, focus, getAlert, getAllButtons, getAllFields, getAllLinks, getAllWindowIds, getAllWindowNames, getAllWindowTitles, getAttribute, getAttributeFromAllWindows, getBodyText, getConfirmation, getCookie, getCookieByName, getCssCount, getCursorPosition, getElementHeight, getElementIndex, getElementPositionLeft, getElementPositionTop, getElementWidth, getExpression, getHtmlSource, getLocation, getLog, getMouseSpeed, getPrompt, getSelectedId, getSelectedIds, getSelectedIndex, getSelectedIndexes, getSelectedLabel, getSelectedLabels, getSelectedValue, getSelectedValues, getSelectOptions, getSpeed, getTable, getText, getTitle, getValue, getWhetherThisFrameMatchFrameExpression, getWhetherThisWindowMatchWindowExpression, getXpathCount, goBack, highlight, ignoreAttributesWithoutValue, isAlertPresent, isChecked, isConfirmationPresent, isCookiePresent, isEditable, isElementPresent, isOrdered, isPromptPresent, isSomethingSelected, isTextPresent, isVisible, keyDown, keyDownNative, keyPressNative, keyUp, keyUpNative, metaKeyDown, metaKeyUp, mouseDown, mouseDownAt, mouseDownRight, mouseDownRightAt, mouseMove, mouseMoveAt, mouseOut, mouseOver, mouseUp, mouseUpAt, mouseUpRight, mouseUpRightAt, open, openWindow, refresh, removeAllSelections, removeScript, removeSelection, retrieveLastRemoteControlLogs, rollup, runScript, select, selectFrame, selectPopUp, selectWindow, setBrowserLogLevel, setContext, setCursorPosition, setExtensionJs, setMouseSpeed, setSpeed, setTimeout, shiftKeyDown, shiftKeyUp, showContextualBanner, showContextualBanner, shutDownSeleniumServer, start, start, stop, submit, type, typeKeys, uncheck, useXpathLibrary, waitForFrameToLoad, waitForPopUp, windowFocus, windowMaximize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.thoughtworks.selenium.Selenium
addCustomRequestHeader, addLocationStrategy, addScript, addSelection, allowNativeXpath, altKeyDown, altKeyUp, answerOnNextPrompt, assignId, attachFile, captureEntirePageScreenshot, captureEntirePageScreenshotToString, captureNetworkTraffic, captureScreenshot, captureScreenshotToString, check, chooseCancelOnNextConfirmation, chooseOkOnNextConfirmation, click, clickAt, close, contextMenu, contextMenuAt, controlKeyDown, controlKeyUp, createCookie, deleteAllVisibleCookies, deleteCookie, deselectPopUp, doubleClick, doubleClickAt, dragAndDrop, dragAndDropToObject, dragdrop, fireEvent, focus, getAlert, getAllButtons, getAllFields, getAllLinks, getAllWindowIds, getAllWindowNames, getAllWindowTitles, getAttribute, getAttributeFromAllWindows, getBodyText, getConfirmation, getCookie, getCookieByName, getCssCount, getCursorPosition, getElementHeight, getElementIndex, getElementPositionLeft, getElementPositionTop, getElementWidth, getExpression, getHtmlSource, getLocation, getLog, getMouseSpeed, getPrompt, getSelectedId, getSelectedIds, getSelectedIndex, getSelectedIndexes, getSelectedLabel, getSelectedLabels, getSelectedValue, getSelectedValues, getSelectOptions, getSpeed, getTable, getText, getTitle, getValue, getWhetherThisFrameMatchFrameExpression, getWhetherThisWindowMatchWindowExpression, getXpathCount, goBack, highlight, ignoreAttributesWithoutValue, isAlertPresent, isChecked, isConfirmationPresent, isCookiePresent, isEditable, isElementPresent, isOrdered, isPromptPresent, isSomethingSelected, isTextPresent, isVisible, keyDown, keyDownNative, keyPressNative, keyUp, keyUpNative, metaKeyDown, metaKeyUp, mouseDown, mouseDownAt, mouseDownRight, mouseDownRightAt, mouseMove, mouseMoveAt, mouseOut, mouseOver, mouseUp, mouseUpAt, mouseUpRight, mouseUpRightAt, open, openWindow, refresh, removeAllSelections, removeScript, removeSelection, retrieveLastRemoteControlLogs, rollup, runScript, select, selectFrame, selectPopUp, selectWindow, setBrowserLogLevel, setContext, setCursorPosition, setExtensionJs, setMouseSpeed, setSpeed, setTimeout, shiftKeyDown, shiftKeyUp, showContextualBanner, showContextualBanner, shutDownSeleniumServer, start, start, stop, submit, type, typeKeys, uncheck, useXpathLibrary, waitForFrameToLoad, waitForPopUp, windowFocus, windowMaximize
 

Field Detail

WIKI_CONTENT_XPATH

public static final String WIKI_CONTENT_XPATH
See Also:
Constant Field Values

DOWN_KEY

public static final String DOWN_KEY
See Also:
Constant Field Values

UP_KEY

public static final String UP_KEY
See Also:
Constant Field Values
Method Detail

getBrowser

public com.atlassian.selenium.Browser getBrowser()
Specified by:
getBrowser in interface com.atlassian.selenium.SeleniumClient
Overrides:
getBrowser in class com.atlassian.selenium.SingleBrowserSeleniumClient

getInstance

public static ConfluenceSeleniumClient getInstance()

setScriptsFinishedPluginExpected

public void setScriptsFinishedPluginExpected(boolean expected)

getBrowserVersion

public double getBrowserVersion()

selectTopFrame

public void selectTopFrame()

cleanUp

public void cleanUp()
Resets the selenium client to a default state so that we can not slow down the tests run accidentally anymore.


open

public void open(String url,
                 long timeoutMillis)
Overridden to append the context path in front of the url.

Specified by:
open in interface com.atlassian.selenium.SeleniumClient
Overrides:
open in class com.atlassian.selenium.SingleBrowserSeleniumClient

openAbsoluteURL

public void openAbsoluteURL(String url,
                            long timeoutMillis)

openAbsoluteURL

public void openAbsoluteURL(String url)

waitForScriptsToLoad

public void waitForScriptsToLoad()

waitForPageToLoad

public void waitForPageToLoad(long timeoutMillis)
Specified by:
waitForPageToLoad in interface com.atlassian.selenium.SeleniumClient
Overrides:
waitForPageToLoad in class com.atlassian.selenium.SingleBrowserSeleniumClient

waitForPageToLoad

public void waitForPageToLoad(String timeout)
Override to make sure all Javascript has finished loading before returning. This relies on the SeleniumSetupTest.SCRIPTS_FINISHED_PLUGIN being enabled (which is done during setUp).

Specified by:
waitForPageToLoad in interface com.thoughtworks.selenium.Selenium
Overrides:
waitForPageToLoad in class com.thoughtworks.selenium.DefaultSelenium

waitForCondition

public void waitForCondition(String javascript,
                             String timeoutMillis)
Runs the provided Javascript statement in the context of the test page, not the Selenium tester like DefaultSelenium.waitForCondition(String, String) does. Use waitForFunction(String, String) for executing more than one statement.

Specified by:
waitForCondition in interface com.thoughtworks.selenium.Selenium
Overrides:
waitForCondition in class com.thoughtworks.selenium.DefaultSelenium

waitForFunction

public void waitForFunction(String javascript,
                            String timeoutMillis)
Runs the provided Javascript function in the context of the test page. The function should contain a return statement to evaluate.

Throws:
com.thoughtworks.selenium.SeleniumException - a wrapped exception from selenium which indicates the condition that failed to run.

waitForFunction

public void waitForFunction(String javascript)

waitForJQueryElementSelector

public void waitForJQueryElementSelector(String selector)
Blocks until an element is found with the specified jQuery selector (or until the action timeout is reached). This method will automatically search within iframes as well if the element cannot be found on the main page. This was introduced because jQuery is more reliable than using native selenium xpath selectors.

Parameters:
selector - jQuery element selector

waitForJQueryElementSelector

public void waitForJQueryElementSelector(String selector,
                                         long timeoutMillis)
Blocks until an element is found with the specified jQuery selector (or until the given timeout is reached). This method will automatically search within iframes as well if the element cannot be found on the main page. This was introduced because jQuery is more reliable than using native selenium xpath selectors.

Parameters:
selector - jQuery element selector
timeoutMillis - time to wait for the selector to find something

waitForJQueryElementSelectorCount

public void waitForJQueryElementSelectorCount(String selector,
                                              int count)
Blocks until a certain number of elements are found with the specified jQuery selector (or until the action timeout is reached). This method will automatically search within iframes as well if the element cannot be found on the main page. This was introduced because jQuery is more reliable than using native selenium xpath selectors.

Parameters:
selector - jQuery element selector
count - the number of times the selector should be found

getJQueryElementSelectorHeight

public int getJQueryElementSelectorHeight(String selector)
Gets the height of the supplied jQuery selector.

Parameters:
selector - jQuery element selector

waitForJqueryEventTriggered

public void waitForJqueryEventTriggered(String eventName,
                                        String selector)
Will wait for a specfic event to be triggered.

Parameters:
eventName - The name of the event to listen for
selector - The selector used for binding

isJQueryElementSelectorPresent

public boolean isJQueryElementSelectorPresent(String selector)
Returns true if the given JQuery selector returns at least one result.


hasSelectorWithText

public boolean hasSelectorWithText(String selector,
                                   String text)
Returns true if the given JQuery selector returns at least one result containing the supplied text.


waitForNoJQueryElementSelector

public void waitForNoJQueryElementSelector(String selector)

getEvalAsBoolean

public boolean getEvalAsBoolean(String javascript)

getEvalAsInteger

public int getEvalAsInteger(String javascript)

getEval

public String getEval(String javascript)
Runs the provided Javascript statement in the context of the test page, not the Selenium tester like DefaultSelenium.getEval(String) does. Use getEvalFunction(String) for executing more than one statement.

Specified by:
getEval in interface com.thoughtworks.selenium.Selenium
Overrides:
getEval in class com.thoughtworks.selenium.DefaultSelenium

getEvalFunction

public String getEvalFunction(String function)
Runs the provided Javascript function in the context of the test page. The function should contain a return statement to evaluate and return.

Parameters:
function - a javascript function body including the return statement

getEvalFunction

public String getEvalFunction(String... functionLines)
Varargs version of getEvalFunction(String) which joins together its arguments with newlines.


getEvalListFunction

public List<String> getEvalListFunction(String... functionLines)
Version of getEvalFunction(String...) which executes a JS function which returns a list, joins the result on the client side using commas, then splits it back into a list to return.


typeInElementWithId

public void typeInElementWithId(String elementId,
                                String text)

typeWithLastCharFullKeyEvents

public void typeWithLastCharFullKeyEvents(String locator,
                                          String text)
Types text in the field specified by the locator. Any text previously in the field is cleared out. Most importantly, key events are only fired on the last character. This method has been introduced to reduce flakiness in FF on BEAC where all the keys aren't always typed into the field (according to screenshots).


waitUntilRemoved

public void waitUntilRemoved(String selector)
Waits until the elements matched by the supplied selector are removed from the DOM.


waitUntilHiddenById

public void waitUntilHiddenById(String elementId)
Waits until the element with the supplied id is hidden or until the default timeout expires. Elements hidden via jQuery or via the addition of "hidden" class are found.


waitUntilVisible

public void waitUntilVisible(String selector)
Waits until the element(s) matched by the supplied selector is visible or until the default timeout expires.


waitUntilVisibleById

public void waitUntilVisibleById(String elementId)
Waits until the element with the supplied id is visible or until the default timeout expires.


waitUntilFocused

public void waitUntilFocused(String elementId)
Waits until the element with the supplied id has cursor focus or until the default timeout expires.


pressBackspace

public void pressBackspace(String elementLocator)
Simulates pressing the backspace key in the element.


pressEnter

public void pressEnter(String elementLocator,
                       boolean waitForPageToLoad)
Simulates pressing the enter key in the element. Note, this method does not work for submitting forms.


pressTab

public void pressTab(String elementLocator)
Simulates pressing the tab key in the element.


pressEscape

public void pressEscape(String elementLocator)
Simulates pressing the Esc key in the element.


pressCtrlAndKey

public void pressCtrlAndKey(String locator,
                            String keySequence)
Presses the control key, followed by the key(s) passed in.


pressShiftAndKey

public void pressShiftAndKey(String locator,
                             String keySequence)

pressCtrlAltAndKey

public void pressCtrlAltAndKey(String locator,
                               String keySequence)
Presses the control and alt keys, followed by the key(s) passed in


pressCtrlShiftAndKey

public void pressCtrlShiftAndKey(String locator,
                                 String keySequence)
Presses the control+shift keys, followed by the key(s) passed in.


getContextPath

public String getContextPath()
Context path, including initial slash, eg "/confluence". Empty string if applicable.


getBaseUrl

public String getBaseUrl()

isIE6Mode

public boolean isIE6Mode()

check

public void check(String name,
                  String value)
Checks a checkbox given a name and value. Overrides the default implementation which doesn't work when the value has spaces (see SEL-270).

Specified by:
check in interface com.atlassian.selenium.SeleniumClient
Overrides:
check in class com.atlassian.selenium.SingleBrowserSeleniumClient

click

public void click(String locator,
                  long timeoutMillis)
Specified by:
click in interface com.atlassian.selenium.SeleniumClient
Overrides:
click in class com.atlassian.selenium.SingleBrowserSeleniumClient

click

public void click(String locator,
                  boolean waitForPageToLoad)
Specified by:
click in interface com.atlassian.selenium.SeleniumClient
Overrides:
click in class com.atlassian.selenium.SingleBrowserSeleniumClient

clickLinkWithTextInWikiContent

public void clickLinkWithTextInWikiContent(String text,
                                           boolean waitForPageToLoad)
Clicks a link in the wiki content with the exact text given.


submit

public void submit(String form,
                   long timeoutMillis)
Specified by:
submit in interface com.atlassian.selenium.SeleniumClient
Overrides:
submit in class com.atlassian.selenium.SingleBrowserSeleniumClient

submit

public void submit(String form,
                   boolean waitForPageToLoad)
Specified by:
submit in interface com.atlassian.selenium.SeleniumClient
Overrides:
submit in class com.atlassian.selenium.SingleBrowserSeleniumClient

submit

public void submit(String form,
                   boolean waitForPageToLoad,
                   boolean onlyFireEvent)

keyPressOnly

public void keyPressOnly(String locator,
                         String key)

pressCtrlAndKeyDownOnly

public void pressCtrlAndKeyDownOnly(String locator,
                                    String keySequence)
Use this method for key presses that will load a new page.


toHexColor

public String toHexColor(String colorText)
Converts style color "rbg(1, 2, 3)", or "#010203" into a hex color "010203". Used to provide a standard for as the style color format varies by browser.


getMetadata

public String getMetadata(String key)

getMetadataLong

public long getMetadataLong(String key)

getMetadataBoolean

public boolean getMetadataBoolean(String key)


Copyright © 2003-2013 Atlassian. All Rights Reserved.