com.atlassian.jira.webtest.selenium
Class JiraSeleniumTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.atlassian.selenium.SeleniumTest
              extended by com.atlassian.jira.webtest.selenium.JiraSeleniumTest
All Implemented Interfaces:
EnvironmentAware, com.atlassian.performance.junit.PerformanceTest, junit.framework.Test
Direct Known Subclasses:
AbstractAuiDialogTest, AbstractPluggableRendererComponents, AbstractReloadablePluginsSeleniumTest, AbstractTestAjaxUserPicker, AbstractTestBrowseProjects, AbstractTestJqlAutoComplete, AbstractTestMultiSelectField, GadgetTest, JiraVisualRegressionTest, PortalPageTestCase, Test500Page, TestActivityStream, TestAssigneeFieldNoContext, TestBrowseProjects, TestBulkEdit, TestBulkEditGroupMembers, TestCalendarPopUp, TestChartsView, TestCommentPermlink, TestDashboard, TestDashboardEditing, TestDashboardGeneral, TestDashboardMessages, TestDashboardPermissions, TestDashboardShared, TestDeleteIssueLink, TestEditFilter, TestEditIssueComponentPicker, TestEditIssueVersionPickers, TestEditLabelsAnonymous, TestFilterBrowser, TestGadgetPermissions, TestGadgetWhitelistUpgrade, TestHideShowToggleOnViewIssueScreen, TestIssueAggregateTimeTracking, TestIssueNavigatorCaretAndFocus, TestIssueNavigatorCollapsing, TestIssueNavigatorFavourites, TestIssueNavigatorKeyboardNavigation, TestIssuesProjectTabPanel, TestJqlDecimalValuesComplete, TestJqlQueryTextBox, TestJQueryLocatorStrategyInSelenium, TestKeyboardShortcutHintsInIssueNavigator, TestKeyboardUpCommandToViewIssue, TestLoginGadget, TestManageDashboardsControls, TestManageDashboardsPermissionsCollapsor, TestManageFiltersControls, TestManageShareBrowse, TestMentionAutocomplete, TestMultiSelectCustomField, TestOpsBar, TestPopupGroupPicker, TestSetup, TestSetupDatabase, TestShareDashboardFavourites, TestSubTaskQuickCreation, TestTranslation, TestUserMenu, TestViewIssue, TestVotingAndWatching, TestXmlImport, UnitTestRunner

public abstract class JiraSeleniumTest
extends com.atlassian.selenium.SeleniumTest
implements EnvironmentAware


Nested Class Summary
static interface JiraSeleniumTest.Check
           
 
Field Summary
static String ADMIN_PASSWORD
           
static String ADMIN_USERNAME
           
protected  Backdoor backdoor
           
protected static int DROP_DOWN_WAIT
           
protected  JIRAEnvironmentData environmentData
          A member variable back to the Selenium interface
protected static String HSP_1
           
 org.apache.log4j.Logger logger
           
protected static String MKY_1
           
protected static String PAGE_LOAD_WAIT
           
protected static long PAGE_LOAD_WAIT_TIME
           
protected static int PRESENT_TO_VISIBLE_DELAY
           
static String VK_DOWN
           
static String VK_ESC
           
static String VK_UP
           
 
Fields inherited from class com.atlassian.selenium.SeleniumTest
assertThat, client, config, recorder
 
Constructor Summary
JiraSeleniumTest()
           
JiraSeleniumTest(JIRAEnvironmentData environmentData)
           
 
Method Summary
 void assertFalse(String message, JiraSeleniumTest.Check assertion)
           
 void assertFalse(String message, JiraSeleniumTest.Check assertion, int timeout)
           
 void assertTrue(String message, JiraSeleniumTest.Check assertion)
           
 void assertTrue(String message, JiraSeleniumTest.Check assertion, int timeout)
           
protected  void backgroundLogout()
           
protected  SeleniumContext context()
           
 Administration getAdministration()
           
 Backdoor getBackdoor()
          Deprecated. Use #backdoor# instead. Since v5.0.
 JIRAEnvironmentData getEnvironmentData()
           
 Navigator getNavigator()
           
 com.atlassian.selenium.SeleniumConfiguration getSeleniumConfiguration()
           
 UserPreferences getUserPreferences()
           
protected  JIRAWebTest getWebUnitTest()
           
 String getXsrfToken()
           
protected  GlobalPages globalPages()
           
protected  void internalSetup()
           
protected  boolean isBeforeJdk15()
          Checks the current JDK version from the JIRA system information page.
protected  boolean isKickAssEnabled()
           
 boolean isUserAgentFirefox()
           
 void log(String msg)
           
 void onSetUp()
           
protected  void onTearDown()
           
protected  void restoreBlankInstance()
           
protected  void restoreData(String file)
           
protected  void restoreData(String path, String file)
           
protected  void restoreData(String path, String file, boolean reloadPlugins)
           
protected  void restoreDataWithPluginsReload(String file)
           
protected  void restoreDataWithReplacedTokens(String file, Map<String,String> replacements)
           
protected  void restoreI18nData(String file)
           
protected  void restoreUnsetupJIRA()
           
protected  void restoreViaBackdoor(String filename)
          Restores an XML import file via the Backdoor after confirming that the Selenium session is sane.
protected  void restoreViaBackdoorAndGoToDashboard(String filename)
          Deprecated. Use the #backdoor# restore method instead, and login as whichever user is needed for the test. Since v5.0.
 void runBare()
          The outer most edge of a JUnit Test.
protected  void runBareTestCase()
          This is a basicly copy and paste of TestCase.runBare(), except we capture a screenshot if the execution of the test fails.
protected  void selectMainWindow()
           
 void setEnvironmentData(JIRAEnvironmentData environmentData)
           
 void setSeleniumTestListener(JiraSeleniumTestListener listener)
           
protected static junit.framework.Test suiteFor(Class testSuiteClass)
          If you put a class in your test unit class to this then IDEA can run the test in one suite rather than setting it up and pulling it dfown completely for each test method.
protected  DefaultTimeouts timeouts()
           
 void turnOffProfiling()
           
 void turnOnProfiling()
           
protected  void visibleByTimeoutWithDelay(String locator, long timeout)
          Use this instead of visibleByTimeout when waiting for an ajax call to complete.
 void waitFor(int millis)
          Deprecated. there is always something on the page to wait for (incl. non-existence of something)!!! usage of this method will lead to slow tests with intermittent failures
protected  void waitForContentUpdate()
           
protected  void waitForRestore()
           
 
Methods inherited from class com.atlassian.selenium.SeleniumTest
getRecorder, getSeleniumClient, setUp, tearDown
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface junit.framework.Test
countTestCases, run
 

Field Detail

logger

public final org.apache.log4j.Logger logger

PRESENT_TO_VISIBLE_DELAY

protected static final int PRESENT_TO_VISIBLE_DELAY
See Also:
Constant Field Values

DROP_DOWN_WAIT

protected static final int DROP_DOWN_WAIT
See Also:
Constant Field Values

VK_DOWN

public static final String VK_DOWN
See Also:
Constant Field Values

VK_UP

public static final String VK_UP
See Also:
Constant Field Values

VK_ESC

public static final String VK_ESC
See Also:
Constant Field Values

ADMIN_USERNAME

public static final String ADMIN_USERNAME
See Also:
Constant Field Values

ADMIN_PASSWORD

public static final String ADMIN_PASSWORD
See Also:
Constant Field Values

HSP_1

protected static final String HSP_1
See Also:
Constant Field Values

MKY_1

protected static final String MKY_1
See Also:
Constant Field Values

environmentData

protected JIRAEnvironmentData environmentData
A member variable back to the Selenium interface


backdoor

protected Backdoor backdoor

PAGE_LOAD_WAIT_TIME

protected static final long PAGE_LOAD_WAIT_TIME
See Also:
Constant Field Values

PAGE_LOAD_WAIT

protected static final String PAGE_LOAD_WAIT
Constructor Detail

JiraSeleniumTest

public JiraSeleniumTest()

JiraSeleniumTest

public JiraSeleniumTest(JIRAEnvironmentData environmentData)
Method Detail

log

public void log(String msg)

onSetUp

public void onSetUp()
Overrides:
onSetUp in class com.atlassian.selenium.SeleniumTest

internalSetup

protected void internalSetup()

runBare

public void runBare()
             throws Throwable
The outer most edge of a JUnit Test. All things start and end here.

Overrides:
runBare in class junit.framework.TestCase
Throws:
Throwable
See Also:
TestCase.runBare()

runBareTestCase

protected void runBareTestCase()
                        throws Throwable
This is a basicly copy and paste of TestCase.runBare(), except we capture a screenshot if the execution of the test fails.

Throws:
Throwable - on error

onTearDown

protected void onTearDown()
                   throws Exception
Overrides:
onTearDown in class com.atlassian.selenium.SeleniumTest
Throws:
Exception

restoreData

protected void restoreData(String file)

restoreDataWithPluginsReload

protected final void restoreDataWithPluginsReload(String file)

restoreData

protected final void restoreData(String path,
                                 String file)

restoreData

protected void restoreData(String path,
                           String file,
                           boolean reloadPlugins)

restoreI18nData

protected void restoreI18nData(String file)

restoreDataWithReplacedTokens

protected void restoreDataWithReplacedTokens(String file,
                                             Map<String,String> replacements)

restoreBlankInstance

protected void restoreBlankInstance()

restoreUnsetupJIRA

protected void restoreUnsetupJIRA()

restoreViaBackdoor

protected void restoreViaBackdoor(String filename)
Restores an XML import file via the Backdoor after confirming that the Selenium session is sane.

Parameters:
filename - the XML file to restore

restoreViaBackdoorAndGoToDashboard

protected void restoreViaBackdoorAndGoToDashboard(String filename)
Deprecated. Use the #backdoor# restore method instead, and login as whichever user is needed for the test. Since v5.0.

Restores an XML import file via the Backdoor after confirming that the Selenium session is sane. Then goes to the dashboard because many tests assume that it's where they start.

Don't use this method! Just go to the first URL needed by your test!

Parameters:
filename - the XML file to restore

waitForRestore

protected void waitForRestore()

suiteFor

protected static junit.framework.Test suiteFor(Class testSuiteClass)
If you put a class in your test unit class to this then IDEA can run the test in one suite rather than setting it up and pulling it dfown completely for each test method. This will make running Selenium tests in IDEA and order of magnitude faster.

public static Test suite() { return suiteFor(YourSeleniumUnitTest.class); }

Parameters:
testSuiteClass - the unit test class to run
Returns:
a Test suit built by SeleniumTestSuiteBuilder

isBeforeJdk15

protected boolean isBeforeJdk15()
Checks the current JDK version from the JIRA system information page.

NOTE: This will move the current page to the JIRA system informatoin page.

Returns:
true if the JDK version is before 1.5

getEnvironmentData

public JIRAEnvironmentData getEnvironmentData()

setEnvironmentData

public void setEnvironmentData(JIRAEnvironmentData environmentData)
Specified by:
setEnvironmentData in interface EnvironmentAware

setSeleniumTestListener

public void setSeleniumTestListener(JiraSeleniumTestListener listener)

getWebUnitTest

protected JIRAWebTest getWebUnitTest()

isKickAssEnabled

protected boolean isKickAssEnabled()

waitForContentUpdate

protected void waitForContentUpdate()

getAdministration

public Administration getAdministration()

getBackdoor

public Backdoor getBackdoor()
Deprecated. Use #backdoor# instead. Since v5.0.

Returns:
a backdoor

getNavigator

public Navigator getNavigator()

getUserPreferences

public UserPreferences getUserPreferences()

timeouts

protected final DefaultTimeouts timeouts()

context

protected final SeleniumContext context()

globalPages

protected final GlobalPages globalPages()

turnOnProfiling

public void turnOnProfiling()

turnOffProfiling

public void turnOffProfiling()

isUserAgentFirefox

public boolean isUserAgentFirefox()

waitFor

@Deprecated
public void waitFor(int millis)
Deprecated. there is always something on the page to wait for (incl. non-existence of something)!!! usage of this method will lead to slow tests with intermittent failures

Waits for the specified number of milliseconds. A glorified Thread.sleep(). Use this sparingly! If you want to assert that something is shown after a timeout, use SeleniumAssertions instead!

This method should only be used when asserting the negative case (something doesn't show up after a timeout)

Parameters:
millis - - how long to wait
See Also:
TimedCondition

getSeleniumConfiguration

public com.atlassian.selenium.SeleniumConfiguration getSeleniumConfiguration()
Specified by:
getSeleniumConfiguration in class com.atlassian.selenium.SeleniumTest

visibleByTimeoutWithDelay

protected void visibleByTimeoutWithDelay(String locator,
                                         long timeout)
Use this instead of visibleByTimeout when waiting for an ajax call to complete. This is similar to assertThat.visibleByTimeout, except that instead of (selenium.isElementPresent(element) && selenium.isVisible(element)), elementPresentByTimeout is used first, then a delay (See PRESENT_TO_VISIBLE_DELAY), before visibleByTimeout is called.

Parameters:
locator - Selenium element locator
timeout - timeout to use for present and visible timeouts

assertFalse

public void assertFalse(String message,
                        JiraSeleniumTest.Check assertion)

assertTrue

public void assertTrue(String message,
                       JiraSeleniumTest.Check assertion)

assertFalse

public void assertFalse(String message,
                        JiraSeleniumTest.Check assertion,
                        int timeout)

assertTrue

public void assertTrue(String message,
                       JiraSeleniumTest.Check assertion,
                       int timeout)

getXsrfToken

public String getXsrfToken()

backgroundLogout

protected final void backgroundLogout()
                               throws Exception
Throws:
Exception

selectMainWindow

protected final void selectMainWindow()


Copyright © 2002-2013 Atlassian. All Rights Reserved.