com.atlassian.confluence.selenium.client
Class ConfluenceSeleniumClient

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

public class ConfluenceSeleniumClient
extends com.atlassian.selenium.SeleniumClient

Extends the Atlassian Selenium client to provide Confluence specific methods.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.atlassian.selenium.SeleniumClient
com.atlassian.selenium.SeleniumClient.Browser
 
Field Summary
static java.lang.String DOWN_KEY
           
static java.lang.String UP_KEY
           
static java.lang.String WIKI_CONTENT_XPATH
           
 
Fields inherited from class com.atlassian.selenium.SeleniumClient
ACTION_WAIT, PAGE_LOAD_WAIT
 
Fields inherited from class com.thoughtworks.selenium.DefaultSelenium
commandProcessor
 
Method Summary
 void check(java.lang.String name, java.lang.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(java.lang.String locator, boolean waitForPageToLoad)
           
 void click(java.lang.String locator, long timeoutMillis)
           
 void clickLinkWithTextInWikiContent(java.lang.String text, boolean waitForPageToLoad)
          Clicks a link in the wiki content with the exact text given.
 java.lang.String getBaseUrl()
           
 double getBrowserVersion()
           
 java.lang.String getContextPath()
          Context path, including initial slash, eg "/confluence".
 java.lang.String getEval(java.lang.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(java.lang.String javascript)
           
 java.lang.String getEvalFunction(java.lang.String... functionLines)
          Varargs version of getEvalFunction(String) which joins together its arguments with newlines.
 java.lang.String getEvalFunction(java.lang.String function)
          Runs the provided Javascript function in the context of the test page.
 java.util.List<java.lang.String> getEvalListFunction(java.lang.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()
           
 boolean isIE6Mode()
           
 boolean isJQueryElementSelectorPresent(java.lang.String selector)
          Returns true if the given JQuery selector returns at least one result.
 void keyPressOnly(java.lang.String locator, java.lang.String key)
           
 void open(java.lang.String url, long timeoutMillis)
          Overridden to append the context path in front of the url.
 void pressBackspace(java.lang.String elementLocator)
          Simulates pressing the backspace key in the element.
 void pressCtrlAltAndKey(java.lang.String locator, java.lang.String keySequence)
          Presses the control and alt keys, followed by the key(s) passed in
 void pressCtrlAndKey(java.lang.String locator, java.lang.String keySequence)
          Presses the control key, followed by the key(s) passed in.
 void pressCtrlAndKeyDownOnly(java.lang.String locator, java.lang.String keySequence)
          Use this method for key presses that will load a new page.
 void pressCtrlShiftAndKey(java.lang.String locator, java.lang.String keySequence)
          Presses the control+shift keys, followed by the key(s) passed in.
 void pressEnter(java.lang.String elementLocator, boolean waitForPageToLoad)
          Simulates pressing the enter key in the element.
 void pressEscape(java.lang.String elementLocator)
          Simulates pressing the Esc key in the element.
 void pressShiftAndKey(java.lang.String locator, java.lang.String keySequence)
           
 void pressTab(java.lang.String elementLocator)
          Simulates pressing the tab key in the element.
 void setScriptsFinishedPluginExpected(boolean expected)
           
 void submit(java.lang.String form, boolean waitForPageToLoad)
           
 void submit(java.lang.String form, long timeoutMillis)
           
 void typeInElementWithId(java.lang.String elementId, java.lang.String text)
           
 void typeWithLastCharFullKeyEvents(java.lang.String locator, java.lang.String text)
          Types text in the field specified by the locator.
 void waitForCondition(java.lang.String javascript, java.lang.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(java.lang.String javascript)
           
 void waitForFunction(java.lang.String javascript, java.lang.String timeoutMillis)
          Runs the provided Javascript function in the context of the test page.
 void waitForJQueryElementSelector(java.lang.String selector)
          Blocks until an element is found with the specified jQuery selector (or until the action timeout is reached).
 void waitForNoJQueryElementSelector(java.lang.String selector)
           
 void waitForPageToLoad(long timeoutMillis)
           
 void waitForPageToLoad(java.lang.String timeout)
          Override to make sure all Javascript has finished loading before returning.
 void waitForScriptsToLoad()
           
 void waitUntilHidden(java.lang.String elementId)
          Waits until the element with the supplied id is hidden or until the default timeout expires.
 void waitUntilVisible(java.lang.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.SeleniumClient
clickAndWaitForAjaxWithJquery, clickAndWaitForAjaxWithJquery, clickButton, clickButtonAndWaitForAjaxWithJquery, clickButtonWithName, clickButtonWithNameAndWaitForAjaxWithJquery, clickElementWithClass, clickElementWithClassAndWaitForAjaxWithJquery, clickElementWithCss, clickElementWithCssAndWaitForAjaxWithJquery, clickElementWithTitle, clickElementWithTitleAndWaitForAjaxWithJquery, clickElementWithXpath, clickElementWithXpathAndWaitForAjaxWithJquery, clickLinkWithText, getBrowser, hasJquery, keyPress, open, openNoWait, selectOption, selectOptionAndWaitForAjaxWithJquery, start, typeInElementWithCss, typeInElementWithName, typeWithFullKeyEvents, typeWithFullKeyEvents, waitForAjaxWithJquery, waitForAjaxWithJquery, waitForCondition, waitForCondition, waitForPageToLoad
 
Methods inherited from class com.thoughtworks.selenium.DefaultSelenium
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, getCursorPosition, getElementHeight, getElementIndex, getElementPositionLeft, getElementPositionTop, getElementWidth, getExpression, getHtmlSource, getLocation, 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, 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
 

Field Detail

WIKI_CONTENT_XPATH

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

DOWN_KEY

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

UP_KEY

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

getInstance

public static ConfluenceSeleniumClient getInstance()

setScriptsFinishedPluginExpected

public void setScriptsFinishedPluginExpected(boolean expected)

getBrowserVersion

public double getBrowserVersion()

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(java.lang.String url,
                 long timeoutMillis)
Overridden to append the context path in front of the url.

Overrides:
open in class com.atlassian.selenium.SeleniumClient

waitForScriptsToLoad

public void waitForScriptsToLoad()

waitForPageToLoad

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

waitForPageToLoad

public void waitForPageToLoad(java.lang.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(java.lang.String javascript,
                             java.lang.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(java.lang.String javascript,
                            java.lang.String timeoutMillis)
Runs the provided Javascript function in the context of the test page. The function should contain a return statement to evaluate.


waitForFunction

public void waitForFunction(java.lang.String javascript)

waitForJQueryElementSelector

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

isJQueryElementSelectorPresent

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


waitForNoJQueryElementSelector

public void waitForNoJQueryElementSelector(java.lang.String selector)

getEvalAsBoolean

public boolean getEvalAsBoolean(java.lang.String javascript)

getEval

public java.lang.String getEval(java.lang.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 java.lang.String getEvalFunction(java.lang.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 java.lang.String getEvalFunction(java.lang.String... functionLines)
Varargs version of getEvalFunction(String) which joins together its arguments with newlines.


getEvalListFunction

public java.util.List<java.lang.String> getEvalListFunction(java.lang.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(java.lang.String elementId,
                                java.lang.String text)

typeWithLastCharFullKeyEvents

public void typeWithLastCharFullKeyEvents(java.lang.String locator,
                                          java.lang.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).


waitUntilHidden

public void waitUntilHidden(java.lang.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(java.lang.String elementId)
Waits until the element with the supplied id is visible or until the default timeout expires.


pressBackspace

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


pressEnter

public void pressEnter(java.lang.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(java.lang.String elementLocator)
Simulates pressing the tab key in the element.


pressEscape

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


pressCtrlAndKey

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


pressShiftAndKey

public void pressShiftAndKey(java.lang.String locator,
                             java.lang.String keySequence)

pressCtrlAltAndKey

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


pressCtrlShiftAndKey

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


getContextPath

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


getBaseUrl

public java.lang.String getBaseUrl()

isIE6Mode

public boolean isIE6Mode()

check

public void check(java.lang.String name,
                  java.lang.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).

Overrides:
check in class com.atlassian.selenium.SeleniumClient

click

public void click(java.lang.String locator,
                  long timeoutMillis)
Overrides:
click in class com.atlassian.selenium.SeleniumClient

click

public void click(java.lang.String locator,
                  boolean waitForPageToLoad)
Overrides:
click in class com.atlassian.selenium.SeleniumClient

clickLinkWithTextInWikiContent

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


submit

public void submit(java.lang.String form,
                   long timeoutMillis)
Overrides:
submit in class com.atlassian.selenium.SeleniumClient

submit

public void submit(java.lang.String form,
                   boolean waitForPageToLoad)
Overrides:
submit in class com.atlassian.selenium.SeleniumClient

keyPressOnly

public void keyPressOnly(java.lang.String locator,
                         java.lang.String key)

pressCtrlAndKeyDownOnly

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



Copyright © 2003-2011 Atlassian. All Rights Reserved.