public class GenericInteractionMethods extends Object
Created by jordam on 2017-02-08.
| Modifier and Type | Field and Description |
|---|---|
int |
standardTimeout |
TestCase |
testCase |
| Constructor and Description |
|---|
GenericInteractionMethods(TestCase testCase)
Constructor to enable interaction with Java GUIs
|
| Modifier and Type | Method and Description |
|---|---|
void |
activateTab(JavaWindow window,
String tabText) |
ArrayList<Object> |
allSubElementsOf(Object component)
Retrieves all sub-elements (recursively) of the object provided.
|
void |
bringWindowOfElementToFront(GuiComponent component) |
boolean |
checkboxIsChecked(GuiComponent component,
int timeoutInSeconds)
Returns the current status of a checkbox.
|
void |
chooseRadioButton(GuiComponent guiElement,
String textOfElementToChoose)
When implemented, this method will set radio button status.
|
void |
click(GuiComponent guiElement) |
void |
clickByRawMouseAction(GuiComponent guiElement)
Performs a left mouse button click upon the given element.
|
void |
clickElementWithText(GuiComponent parentElement,
String textOfElementToClick)
Finds the element with the specified text and click on it.
|
void |
clickElementWithText(JavaWindow window,
String textOfElementToClick)
Finds the element with the specified text and click on it.
|
void |
closeAllWindows() |
void |
closeWindow(JavaWindow window) |
void |
debug_LogCurrentActiveWindows()
Writes currently active window to the test case log
|
boolean |
doesNotExist(GuiComponent guiElement)
Checks if an element does not exist at runtime.
|
boolean |
doesNotExistWithTimeout(GuiComponent guiElement,
int timeoutInSeconds)
Checks if an element exist, but gives the element time to disappear for a timeout.
|
boolean |
exists(GuiComponent guiElement)
Checks if an element exists in the GUI.
|
boolean |
existsWithTimeout(GuiComponent guiElement,
int timeoutInSeconds)
Checks if a component exist, but actually gives it time to appear in the GUI.
|
Object |
getContainerComponent(Object component)
Returns the first parent that has the ability to hold child objects.
|
String |
getDropDownSelectedOption(GuiComponent guiComponent)
Returns the currently selected value of a dropdown
|
List<String> |
getDropDownSelectedOptions(GuiComponent guiElement)
Returns a list of the selected options of a dropdown
|
String |
getName(Object component)
Returns the name of a component, as specified by the programmer when creating the GUI.
|
Object |
getParentComponent(Object component)
Returns the parent element if that can be identified.
|
List<String> |
getSelected(GuiComponent guiComponent) |
String |
getText(GuiComponent guiElement) |
String |
getText(GuiComponent guiElement,
int timeoutInMilliseconds)
Returns the runtime text of the element.
|
String |
getText(Object component)
Returns the current text of a GUI component.
|
void |
haltFurtherExecution() |
void |
hover(GuiComponent guiElement)
Moves the mouse to the given element.
|
boolean |
isDisplayed(GuiComponent guiElement)
Checks if the element is currently displayed (no timeout, no waiting), meaning that it exists, and is set as visible in the GUI.
|
boolean |
isDisplayedWithinTimeout(GuiComponent guiElement,
int timeoutInSeconds)
Checks if the element gets displayed within the timeout.
|
boolean |
isNotDisplayed(GuiComponent guiElement)
Checks if the element is currently not displayed (no timeout, no waiting), meaning that it does not exists, or it is set as non-visible in the GUI.
|
boolean |
isNotDisplayedWithTimeout(GuiComponent guiComponent,
int timeoutInSeconds)
Checks if the element get displayed within the timeout.
|
void |
selectInDropdown(GuiComponent guiElement,
String selection)
Selects a value in a dropdown.
|
void |
setApplicationUnderTest(ApplicationUnderTest app) |
void |
setCheckboxToChecked(GuiComponent component)
Sets a checkbox to be checked (=true).
|
void |
setCheckboxToState(GuiComponent component,
boolean expectedEndState)
Sets a checkbox element to selected state.
|
void |
setCheckboxToState(GuiComponent component,
boolean expectedEndState,
int timeoutInSeconds)
Tries to set a checkbox element to selected state for a certain number of seconds to enable elements to appear or to get enabled.
|
void |
setCheckboxToUnChecked(GuiComponent component)
Sets a checkbox to be un-checked (=false).
|
void |
setSelected(GuiComponent guiComponent,
String... strings) |
void |
tabToNext() |
void |
takeScreenshot()
Saves a screenshot of all screens and writes its save path to the test case log.
|
static void |
takeScreenshot(TestCase testCase) |
void |
trackMousePosition(int timeoutInSeconds) |
void |
type(GuiComponent guiComponent,
int javaAwtEventKeyEvent) |
void |
type(GuiComponent guiComponent,
String text) |
void |
type(int javaAwtEventKeyEvent) |
void |
type(String text) |
void |
wait(int milliseconds)
Pauses execution the stated time.
|
void |
verifyCheckboxIsChecked(GuiComponent component)
Verifies that a checkbox element is checked.
|
void |
verifyCheckboxIsUnChecked(GuiComponent component)
Verifies that a checkbox element is un-checked.
|
void |
verifyCheckboxSelectionStatus(JavaGuiElement guiElement,
boolean expectedToBeSelected) |
void |
verifyCheckboxStatus(GuiComponent component,
boolean expectedStatus)
Verifies the status of a checkbox element.
|
void |
verifyCheckboxStatus(GuiComponent component,
boolean expectedStatus,
int timeoutInSeconds)
Verifies the status of a checkbox element.
|
void |
verifyElementDoesNotExist(GuiComponent guiComponent) |
void |
verifyElementIsDisabled(GuiComponent guiComponent) |
void |
verifyElementIsEnabled(GuiComponent guiComponent) |
void |
verifyElementTextContains(GuiComponent guiElement,
String expectedText)
Retrieves the text of a runtime element and verifies the text against the given oracle.
|
void |
verifyElementTextIsExactly(GuiComponent guiElement,
String expectedText)
Retrieves the text of a runtime element and verifies the text against the given oracle.
|
void |
verifyElementTextIsRegexMatch(GuiComponent guiElement,
String pattern)
Retrieves the text of a runtime element and verifies the text against the given oracle.
|
void |
verifyImage(GuiComponent guiElement,
String s) |
void |
verifyObjectExistence(GuiComponent guiElement)
Verifies that a GUI element exists.
|
void |
verifyObjectExistenceWithTimeout(GuiComponent guiElement,
int timeoutInSeconds)
Verifies object existance, but gives the element time to appear.
|
void |
verifyObjectIsDisplayed(GuiComponent guiElement)
Verifies that a GUI element is displayed, and writes the outcome to the test case log.
|
void |
verifyObjectIsNotDisplayed(GuiComponent guiElement)
Verifies that a GUI element is not displayed, and writes the outcome to the test case log.
|
void |
verifyText(String actualText,
String expectedTest) |
void |
verifyWindowIsDisplayed(JavaWindow javaWindow) |
void |
verifyWindowIsDisplayed(JavaWindow javaWindow,
int timeoutInSeconds) |
void |
verifyWindowIsNotDisplayed(JavaWindow window) |
void |
verifyWindowIsNotDisplayed(JavaWindow window,
int timeoutInSecondsForWindowToDisappear) |
void |
write(GuiComponent guiComponent,
String textToWrite)
Writes the given text to the given component.
|
void |
writeWithoutCheck(GuiComponent guiComponent,
String textToWrite)
Writes the given text to the given component.
|
public TestCase testCase
public int standardTimeout
public GenericInteractionMethods(TestCase testCase)
testCase - The test case to log interactions topublic void setApplicationUnderTest(ApplicationUnderTest app)
public Object getParentComponent(Object component)
component - The component to find the parent of.public Object getContainerComponent(Object component)
component - Component to find the container forpublic ArrayList<Object> allSubElementsOf(Object component)
component - The component to identify sub-elements ofpublic void debug_LogCurrentActiveWindows()
public String getName(Object component)
component - The component to find the name of.public static void takeScreenshot(TestCase testCase)
public void takeScreenshot()
public List<String> getSelected(GuiComponent guiComponent)
public String getText(Object component)
component - The component to find text in.public void bringWindowOfElementToFront(GuiComponent component)
public void click(GuiComponent guiElement)
public void clickByRawMouseAction(GuiComponent guiElement)
guiElement - The element to click.public void clickElementWithText(JavaWindow window, String textOfElementToClick)
window - The JavaWindow to search for the element in.textOfElementToClick - The text to find (exact match, partial match, or regular expression pattern)public void clickElementWithText(GuiComponent parentElement, String textOfElementToClick)
parentElement - The object where to look for sub-elements with the specified text.textOfElementToClick - The text to find (exact match, partial match, or regular expression pattern)public void wait(int milliseconds)
milliseconds - Number of milliseconds to pausepublic void write(GuiComponent guiComponent, String textToWrite)
guiComponent - Element to write to.textToWrite - Text to write.public void writeWithoutCheck(GuiComponent guiComponent, String textToWrite)
guiComponent - Element to write to.textToWrite - Text to write.public void chooseRadioButton(GuiComponent guiElement, String textOfElementToChoose)
guiElement - The radio button element to interact withtextOfElementToChoose - The text of the option to choose. First attempt is exact match, then partial match, then regular expression patternpublic void selectInDropdown(GuiComponent guiElement, String selection)
guiElement - The dropdown element (ComboBox) to select a value inselection - The selection expected to be able to make.public String getDropDownSelectedOption(GuiComponent guiComponent)
guiComponent - The dropdownpublic List<String> getDropDownSelectedOptions(GuiComponent guiElement)
guiElement - The dropdownpublic void verifyElementTextIsExactly(GuiComponent guiElement, String expectedText)
guiElement - The GUI element to grep the text ofexpectedText - The oracle text to verify againstpublic void verifyElementTextContains(GuiComponent guiElement, String expectedText)
guiElement - The GUI element to grep the text ofexpectedText - The oracle text to verify againstpublic void verifyElementTextIsRegexMatch(GuiComponent guiElement, String pattern)
guiElement - The GUI element to grep the text ofpattern - The regular expression pattern to verify againstpublic String getText(GuiComponent guiElement)
public String getText(GuiComponent guiElement, int timeoutInMilliseconds)
guiElement - The element to get the text of.timeoutInMilliseconds - The timeout to wait for the element to appearpublic boolean exists(GuiComponent guiElement)
guiElement - The GUI element to verify existance of.public boolean existsWithTimeout(GuiComponent guiElement, int timeoutInSeconds)
guiElement - Element to check existance of.timeoutInSeconds - Timeout to wait.public boolean doesNotExist(GuiComponent guiElement)
guiElement - Element to check forpublic boolean doesNotExistWithTimeout(GuiComponent guiElement, int timeoutInSeconds)
guiElement - The element to verify does not existtimeoutInSeconds - The time to wait for the element to disappear, if neededpublic boolean isDisplayedWithinTimeout(GuiComponent guiElement, int timeoutInSeconds)
guiElement - The element to check.timeoutInSeconds - The number of seconds to wait for the element to get displayed.public boolean isDisplayed(GuiComponent guiElement)
guiElement - The element to check.public boolean isNotDisplayed(GuiComponent guiElement)
guiElement - The element to check.public boolean isNotDisplayedWithTimeout(GuiComponent guiComponent, int timeoutInSeconds)
guiComponent - The element to checktimeoutInSeconds - The timout to wait for the element to get displayedpublic void verifyObjectIsDisplayed(GuiComponent guiElement)
guiElement - The GUI element to check if it is displayedpublic void verifyObjectIsNotDisplayed(GuiComponent guiElement)
guiElement - The GUI element to check if it is displayed.public void verifyObjectExistence(GuiComponent guiElement)
guiElement - The GUI element to check existance of.public void verifyObjectExistenceWithTimeout(GuiComponent guiElement, int timeoutInSeconds)
guiElement - The GUI element to check for.timeoutInSeconds - The timeout to wait for the element to become present.public void setCheckboxToChecked(GuiComponent component)
component - The checkbox elementpublic void setCheckboxToUnChecked(GuiComponent component)
component - The checkbox elementpublic void setCheckboxToState(GuiComponent component, boolean expectedEndState)
component - The checkbox elementexpectedEndState - The expected state to set the element to (checked = true, un-checked=false).public void setCheckboxToState(GuiComponent component, boolean expectedEndState, int timeoutInSeconds)
component - The checkbox elementexpectedEndState - The expected state to set the element to (checked = true, un-checked=false).timeoutInSeconds - The time, in seconds to wait for successful checkbox interactionpublic boolean checkboxIsChecked(GuiComponent component, int timeoutInSeconds)
component - The checkbox elementtimeoutInSeconds - The number of seconds to wait for the checkbox appearancepublic void verifyCheckboxStatus(GuiComponent component, boolean expectedStatus, int timeoutInSeconds)
component - The checkbox elementexpectedStatus - True if the expectation is that the checkbox should be checked, othervise false.timeoutInSeconds - The timeout to wait for the checkbox element to appear and get the expected status.public void verifyCheckboxStatus(GuiComponent component, boolean expectedStatus)
component - The checkbox elementexpectedStatus - True if the expectation is that the checkbox should be checked, othervise false.public void verifyCheckboxIsChecked(GuiComponent component)
component - The checkbox elementpublic void verifyCheckboxIsUnChecked(GuiComponent component)
component - The checkbox elementpublic void verifyImage(GuiComponent guiElement, String s)
public void type(String text)
public void tabToNext()
public void type(int javaAwtEventKeyEvent)
public void type(GuiComponent guiComponent, int javaAwtEventKeyEvent)
public void type(GuiComponent guiComponent, String text)
public void verifyWindowIsDisplayed(JavaWindow javaWindow)
public void verifyWindowIsDisplayed(JavaWindow javaWindow, int timeoutInSeconds)
public void verifyElementDoesNotExist(GuiComponent guiComponent)
public void verifyWindowIsNotDisplayed(JavaWindow window)
public void verifyWindowIsNotDisplayed(JavaWindow window, int timeoutInSecondsForWindowToDisappear)
public void closeAllWindows()
public void setSelected(GuiComponent guiComponent, String... strings)
public void haltFurtherExecution()
public void verifyCheckboxSelectionStatus(JavaGuiElement guiElement, boolean expectedToBeSelected)
public void closeWindow(JavaWindow window)
public void activateTab(JavaWindow window, String tabText)
public void trackMousePosition(int timeoutInSeconds)
public void hover(GuiComponent guiElement)
guiElement - The element to hover.public void verifyElementIsEnabled(GuiComponent guiComponent)
public void verifyElementIsDisabled(GuiComponent guiComponent)
Copyright © 2019. All rights reserved.