com.atlassian.jira.webtest.selenium.gadgets
Class GadgetTest

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
                  extended by com.atlassian.jira.webtest.selenium.gadgets.GadgetTest
All Implemented Interfaces:
EnvironmentAware, com.atlassian.performance.junit.PerformanceTest, junit.framework.Test
Direct Known Subclasses:
BaseChartGadgetTest, Test2DStatsUpgrade, TestAssignedToMeGadget, TestBugzillaGadget, TestFavouriteFiltersGadget, TestFilterOrProjectPicker, TestFilterPopUp, TestFilterResultsGadget, TestHeatMapGadgetIrrelevantIssues, TestInProgressGadget, TestIntroGadget, TestLabelsGadget, TestPieChartGadgetIrrelevantIssues, TestQuicklinksGadget, TestRoadmapGadget, TestStatsGadgetIrrelevantIssues, TestTextGadget, TestTimeSinceGadget, TestTwoDimensionalStatsGadget, TestVotedIssuesGadget, TestWatchedIssuesGadget, TestWatchedIssuesGadgetResolvedIssues

public abstract class GadgetTest
extends JiraSeleniumTest

Base class for selenium testing JIRA gadgets.

Since:
v4.0

Nested Class Summary
 
Nested classes/interfaces inherited from class com.atlassian.jira.webtest.selenium.JiraSeleniumTest
JiraSeleniumTest.Check
 
Field Summary
protected static int GADGET_DIRECTORY_TIMEOUT
           
protected  Locator openDropdownLocator
           
protected static int TIMEOUT
           
protected  String title
           
 
Fields inherited from class com.atlassian.jira.webtest.selenium.JiraSeleniumTest
ADMIN_PASSWORD, ADMIN_USERNAME, backdoor, DROP_DOWN_WAIT, environmentData, HSP_1, logger, MKY_1, PAGE_LOAD_WAIT, PAGE_LOAD_WAIT_TIME, PRESENT_TO_VISIBLE_DELAY, VK_DOWN, VK_ESC, VK_UP
 
Fields inherited from class com.atlassian.selenium.SeleniumTest
assertThat, client, config, recorder
 
Constructor Summary
GadgetTest()
           
 
Method Summary
 void addGadget(String gadgetTitle)
          Adds a gadget with the given name using the gadget directory.
 void addGadget(String gadgetTitle, String iframeTitle)
          Adds a gadget with the given name using the gadget directory.
protected  void assertAutoComplete(String field, String hint, String... autoCompleteLocators)
          Asserts autocompletion field.
protected  void assertDaysPreviouslyFieldPresent()
          Asserts that the 'Days Previously' text field is present
protected  void assertFieldOptionLabelsPresent(String field, String[] labels)
          Asserts that the given option labels are present for the given field.
 void assertFieldOptionValuePresent(String field, String optionValue)
           
 void assertFieldOptionValuesPresent(String field, String[] optionValues)
          Asserts that the given option values are present for the given field.
protected  void assertGadgetNotVisible(String expectedTitle)
          Asserts that there is no gadget with the title specified
protected  void assertGadgetTitle(String expectedTitle)
          Asserts the title of the gadget.
protected  void assertPeriodFieldPresent()
          Asserts that the 'Period' select field and all its options are present
protected  void assertRefreshIntervalFieldPresent()
          Asserts that the 'Refresh Interval' select field and all its options are present
 void assertSelectFieldError(String field, String badValue, String expectedError)
          Sets a select field to a badValue, submits the form and asserts the expectedMessage is present.
 void assertTextFieldError(String field, String badValue, String expectedError)
          Sets a text field (or hidden field etc.) to the given value, submits the form and asserts the presence of the given error.
protected  boolean clickConfigButton()
          Clicks the gadget configure button
protected  boolean clickRefreshButton()
          Clicks the gadget configure button
protected  void deleteGadget(String gadgetTitle)
          Deletes a gadget if it exists.
protected  String getBaseUrl()
           
protected  void loginAsAdmin()
           
protected  void maximizeGadget(String gadgetTitle)
          Maximizes the gadget if it isn't already
protected  void minimizeGadget(String gadgetTitle)
          Minimizes the gadget if it isn't already
 void onSetUp()
          Loads minimal starting data for gadget testing and does an admin login.
protected  void onTearDown()
           
protected  void restoreGadgetData()
           
protected  void selectByLabels(String selectFieldLocator, String... labels)
          Sets a (multi-) select field by label(s).
protected  void selectDashboardFrame()
           
protected  void selectGadget(String gadgetTitle)
           
protected  void selectProjectOrFilterFromAutoComplete(String field, String hint, String id)
           
protected  void setSelectField(String field, String value)
          Sets a select field to the given value.
protected  void setTextField(String field, String value)
          Sets a text field (or hidden field etc.) to the given value.
protected  void submitGadgetConfig()
          Submits the "form" that is the gadget config view.
protected  void viewGadgetAsAnonymous(String gadgetTitle)
           
protected  void viewGadgetAsAnonymous(String gadgetTitle, Runnable configureGadget)
           
protected  void waitForGadgetConfiguration()
          Waits for a gadget to load by waiting for its configuration form
protected  void waitForGadgetView(String id)
           
 
Methods inherited from class com.atlassian.jira.webtest.selenium.JiraSeleniumTest
assertFalse, assertFalse, assertTrue, assertTrue, backgroundLogout, context, getAdministration, getBackdoor, getEnvironmentData, getNavigator, getSeleniumConfiguration, getUserPreferences, getWebUnitTest, getXsrfToken, globalPages, internalSetup, isBeforeJdk15, isKickAssEnabled, isUserAgentFirefox, log, restoreBlankInstance, restoreData, restoreData, restoreData, restoreDataWithPluginsReload, restoreDataWithReplacedTokens, restoreI18nData, restoreUnsetupJIRA, restoreViaBackdoor, restoreViaBackdoorAndGoToDashboard, runBare, runBareTestCase, selectMainWindow, setEnvironmentData, setSeleniumTestListener, suiteFor, timeouts, turnOffProfiling, turnOnProfiling, visibleByTimeoutWithDelay, waitFor, waitForContentUpdate, 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

TIMEOUT

protected static final int TIMEOUT
See Also:
Constant Field Values

GADGET_DIRECTORY_TIMEOUT

protected static final int GADGET_DIRECTORY_TIMEOUT
See Also:
Constant Field Values

title

protected String title

openDropdownLocator

protected Locator openDropdownLocator
Constructor Detail

GadgetTest

public GadgetTest()
Method Detail

onSetUp

public void onSetUp()
Loads minimal starting data for gadget testing and does an admin login.

Overrides:
onSetUp in class JiraSeleniumTest

onTearDown

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

restoreGadgetData

protected void restoreGadgetData()

loginAsAdmin

protected void loginAsAdmin()

addGadget

public void addGadget(String gadgetTitle)
Adds a gadget with the given name using the gadget directory. The gadget's frame is the currently selected frame on exit from this method.

Parameters:
gadgetTitle - the proper title of the gadget, e.g. "Issues: Resolution Time"

addGadget

public void addGadget(String gadgetTitle,
                      String iframeTitle)
Adds a gadget with the given name using the gadget directory. The gadget's frame is the currently selected frame on exit from this method.

Parameters:
gadgetTitle - the proper title of the gadget, e.g. "Issues: Resolution Time"
iframeTitle - the title of the iframe

assertSelectFieldError

public void assertSelectFieldError(String field,
                                   String badValue,
                                   String expectedError)
Sets a select field to a badValue, submits the form and asserts the expectedMessage is present.

WARNING: the bad value (if not null) cannot be removed. So try to test all valid selections before this one.

Parameters:
field - the name of the field.
badValue - the value to give it that should produce the expectedError
expectedError - the error message expected, if it does not occur, it's a failure.

setSelectField

protected void setSelectField(String field,
                              String value)
Sets a select field to the given value.

WARNING: for any invalid value other than null, it is, to my knowledge, unable to remove the invaild value.

Parameters:
field - the id or the name attribute of the field
value - the option value (not label) to set, or null to remove all existing valid selections

selectByLabels

protected void selectByLabels(String selectFieldLocator,
                              String... labels)
Sets a (multi-) select field by label(s). It will first remove all previously selected labels.

Parameters:
selectFieldLocator - the Selenium locator to locate the select field
labels - the labels to select. To remove all labels, don't pass this parameter.

assertTextFieldError

public void assertTextFieldError(String field,
                                 String badValue,
                                 String expectedError)
Sets a text field (or hidden field etc.) to the given value, submits the form and asserts the presence of the given error.

Parameters:
field - name of the field.
badValue - value to give the field to produce the error.
expectedError - the error expected.

setTextField

protected void setTextField(String field,
                            String value)
Sets a text field (or hidden field etc.) to the given value.

Parameters:
field - name of the field.
value - value to give the field.

assertFieldOptionLabelsPresent

protected void assertFieldOptionLabelsPresent(String field,
                                              String[] labels)
Asserts that the given option labels are present for the given field.

Parameters:
field - the field.
labels - the labels to assert are present.

assertFieldOptionValuesPresent

public void assertFieldOptionValuesPresent(String field,
                                           String[] optionValues)
Asserts that the given option values are present for the given field.

Parameters:
field - the field.
optionValues - the values to assert are present.

assertFieldOptionValuePresent

public void assertFieldOptionValuePresent(String field,
                                          String optionValue)

waitForGadgetConfiguration

protected void waitForGadgetConfiguration()
Waits for a gadget to load by waiting for its configuration form


waitForGadgetView

protected void waitForGadgetView(String id)

selectGadget

protected void selectGadget(String gadgetTitle)

submitGadgetConfig

protected void submitGadgetConfig()
Submits the "form" that is the gadget config view.


assertRefreshIntervalFieldPresent

protected void assertRefreshIntervalFieldPresent()
Asserts that the 'Refresh Interval' select field and all its options are present


assertPeriodFieldPresent

protected void assertPeriodFieldPresent()
Asserts that the 'Period' select field and all its options are present


assertDaysPreviouslyFieldPresent

protected void assertDaysPreviouslyFieldPresent()
Asserts that the 'Days Previously' text field is present


maximizeGadget

protected void maximizeGadget(String gadgetTitle)
Maximizes the gadget if it isn't already

Parameters:
gadgetTitle - the gadget to maximize.

minimizeGadget

protected void minimizeGadget(String gadgetTitle)
Minimizes the gadget if it isn't already

Parameters:
gadgetTitle - the gadget to minimize.

selectDashboardFrame

protected void selectDashboardFrame()

deleteGadget

protected void deleteGadget(String gadgetTitle)
Deletes a gadget if it exists. Returns frame focus to top.

Parameters:
gadgetTitle - the gadget to delete.

clickConfigButton

protected boolean clickConfigButton()
Clicks the gadget configure button

Returns:
true if the button is found and clicked (gadget view was shown), or false if the button is not found, presumably already showing the configuration view

clickRefreshButton

protected boolean clickRefreshButton()
Clicks the gadget configure button

Returns:
true if the button is found and clicked (gadget view was shown), or false if the button is not found, presumably already showing the configuration view

assertGadgetTitle

protected void assertGadgetTitle(String expectedTitle)
Asserts the title of the gadget.

Parameters:
expectedTitle - the expected title of the gadget

assertGadgetNotVisible

protected void assertGadgetNotVisible(String expectedTitle)
Asserts that there is no gadget with the title specified

Parameters:
expectedTitle - the expected title of the gadget

getBaseUrl

protected String getBaseUrl()

selectProjectOrFilterFromAutoComplete

protected void selectProjectOrFilterFromAutoComplete(String field,
                                                     String hint,
                                                     String id)

assertAutoComplete

protected void assertAutoComplete(String field,
                                  String hint,
                                  String... autoCompleteLocators)
Asserts autocompletion field.

Note that the hint should contain only 1 character if you need to assert the exact matching character sequence. For example, if you type "homo", the suggestion list may be created after you typed "h" and before you typed the last "omo". So the highlighted matching character sequence is <strong>h<strong>.

Parameters:
field - the id or name of the field that is autocompleted
hint - the text typed to trigger the suggestion list (at least 3 characters long)
autoCompleteLocators - an array of Selenium locators that should be visible

viewGadgetAsAnonymous

protected void viewGadgetAsAnonymous(String gadgetTitle)

viewGadgetAsAnonymous

protected void viewGadgetAsAnonymous(String gadgetTitle,
                                     Runnable configureGadget)


Copyright © 2002-2012 Atlassian. All Rights Reserved.