Package com.almis.awe.testing.utilities
Class SeleniumUtilities
java.lang.Object
com.almis.awe.testing.utilities.SeleniumUtilities
- All Implemented Interfaces:
IAweInstructions
@ExtendWith({org.springframework.test.context.junit.jupiter.SpringExtension.class,SeleniumExtension.class})
@ContextConfiguration(classes=TestConfig.class,
initializers=org.springframework.boot.test.context.ConfigDataApplicationContextInitializer.class)
public class SeleniumUtilities
extends Object
implements IAweInstructions
Utilities suite for selenium testing
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Accept confirm window and wait for it to disappearprotected void
broadcastMessageToUser
(String user, String text) Broadcast a message to a userprotected void
checkAndCloseMessage
(String messageType) Check a message box and close itprotected void
checkCellContents
(String gridId, String rowId, String columnId, String search) Check cell contentsprotected void
checkCheckboxRadio
(boolean isChecked, String... criteriaNames) Assert if some criteria are checked or notprotected void
checkCriterionContents
(String criterionName, String search) Assert if a criterion contains a textprotected void
checkLogin
(String username, String password, String cssSelector, String checkText) Log into the applicationprotected void
checkLogout
(String cssSelector, String checkText) Log out the applicationprotected void
checkMessageMissing
(String messageType) Check if message is missingprotected void
checkMultipleSelectorContents
(String criterionName, String search) Assert if a selector contains a textprotected void
checkNotVisible
(String cssSelector) Check element is not visibleprotected void
checkNotVisible
(org.openqa.selenium.By selector) Check element is not visibleprotected void
checkPresence
(String cssSelector) Check element is presentprotected void
checkRowContents
(String... searchList) Check if grid contains some textsprotected void
checkRowContentsGrid
(String gridId, String... searchList) Check if grid contains some textsprotected void
checkRowNotContains
(String search) Check if grid doesn't contain some textsprotected void
checkSelectContents
(String criterionName, String search) Assert if a selector contains a textprotected void
checkSelectNumberOfResults
(String criterionName, Integer number) Assert if a selector contains a number of resultsprotected void
checkSuggestContents
(String criterionName, String search) Assert if a suggest contains a textprotected void
Check text inside css selectorprotected void
checkTextContains
(String cssSelector, String text) Check text inside css selectorprotected void
checkTextNotContains
(String cssSelector, String text) heck if selector doesn't contain a textprotected void
checkVisible
(String cssSelector) Check element is visibleprotected void
checkVisible
(org.openqa.selenium.By selector) Check element is visibleprotected void
checkVisibleAndContains
(String cssSelector, String search) Check element is visibleprotected void
Clear text on input selectorprotected void
Click on an elementprotected void
clickButton
(String buttonName) Click on a buttonprotected void
clickButton
(String buttonName, boolean waitForLoadingBar) Click on a buttonprotected void
clickButtonAndConfirm
(String button) Click on confirm button, accept confirmation and accept messageprotected void
clickButtonAndConfirm
(String button, String messageType) Click on confirm button, accept confirmation and accept messageprotected void
Click on a cell on selected rowprotected void
Click on a grid cellprotected void
clickCheckbox
(String criterionName) Click on a checkbox or a radio buttonprotected void
clickCheckbox
(String gridId, String columnId) Click on a checkbox or a radio buttonprotected void
clickCheckbox
(String gridId, String rowId, String columnId) Click on a checkbox or a radio buttonprotected void
clickContextButton
(String... contextButtonOptionList) Click on a context buttonprotected void
Click on datepickerprotected void
Click on datepicker on gridprotected void
Click on datepicker on gridprotected void
clickInfoButton
(String infoButtonName) Click on info buttonprotected void
clickRowContents
(String search) Click on row with a textprotected void
clickRowContents
(String gridId, String search) Click on row with a textprotected void
Click on tabprotected void
clickTreeButton
(String gridId, String rowId) Click on tree buttonprotected void
contextMenu
(String gridId, String rowId, String columnId) Context menu on a gridprotected void
contextMenuRowContents
(String search) Context menu on rowprotected void
contextMenuRowContents
(String gridId, String search) Context menu on rowprotected void
Click on row with a textprotected void
Click on row with a textprotected void
Click on rowGet base URLorg.openqa.selenium.WebDriver
Get driverprotected String
Get criterion textprotected String
Get selected row cell textprotected String
Get grid cell textprotected Integer
Retrieve today day of monthprotected Integer
Retrieve today day of monthprotected void
gotoScreen
(String... menuOptions) Go to a screen defined on the menuprotected void
Starting point; Go to a determined urlprotected void
Pauseprotected void
saveRow()
Click on save row and waitprotected void
Click on save row and waitprotected void
scrollGrid
(String gridId, int horizontal, int vertical) Scroll gridprotected void
Click on search button (ButSch) and wait the grid to loadprotected void
searchAndWait
(String buttonName) Click on search button and wait the grid to loadprotected void
selectAllRowsOfGrid
(String gridId) Select all rows of gridprotected void
selectContain
(String criterionName, String label) Select value on the selectorprotected void
selectContain
(String gridId, String columnId, String label) Select value on the selectorprotected void
selectContain
(String gridId, String rowId, String columnId, String label) Select value on the selectorprotected void
selectDate
(String dateName, CharSequence dateValue) Select a date in datepickerprotected void
selectDate
(String gridId, String columnId, CharSequence dateValue) Select a date in a gridprotected void
selectDate
(String gridId, String rowId, String columnId, CharSequence dateValue) Select a date in a gridprotected void
Select a day in datepicker (current month)protected void
Select a day in datepicker (current month) in a gridprotected void
Select a day in datepicker (current month) in a gridprotected void
selectFirst
(String criterionName) Select first value of the selectprotected void
selectFirst
(String gridId, String columnId) Select first value of the selectprotected void
selectFirst
(String gridId, String rowId, String columnId) Select first value of the selectprotected void
selectLast
(String criterionName) Select first value of the selectprotected void
selectLast
(String gridId, String columnId) Select first value of the selectprotected void
selectLast
(String gridId, String rowId, String columnId) Select first value of the selectprotected void
selectModule
(String moduleName) Select module in module listprotected void
selectMonth
(String dateName, String month) Select a month in datepickerprotected void
selectMonth
(String gridId, String columnId, String month) Select a month in datepicker in a gridprotected void
selectMonth
(String gridId, String rowId, String columnId, String month) Select a month in datepicker in a gridprotected void
selectResult
(String match) Select result on select listprotected void
selectYear
(String dateName, Integer year) Select a year in datepickerprotected void
selectYear
(String gridId, String columnId, Integer year) Select a year in datepicker in a gridprotected void
selectYear
(String gridId, String rowId, String columnId, Integer year) Select a year in datepicker in a gridsetSeleniumModel
(SeleniumModel model) Store selenium modelprotected void
setTestTitle
(String title) Set test titleprotected void
Show mouseprotected void
Click on column headerprotected void
Suggest element which contains labelprotected void
Suggest element which contains labelprotected void
Suggest element which contains labelprotected void
suggestLast
(String criterionName, String search) Suggest element which contains labelprotected void
suggestLast
(String gridId, String columnId, String search) Suggest element which contains labelprotected void
suggestLast
(String gridId, String rowId, String columnId, String search) Suggest element which contains labelprotected void
suggestMultiple
(String criterionName, boolean clear, String search, String label) Suggest or select multiple element which contains labelprotected void
suggestMultiple
(String gridId, String columnId, boolean clear, String search, String label) Suggest or select multiple element which contains labelprotected void
suggestMultiple
(String criterionName, String search, String label) Suggest or select multiple element which contains labelprotected void
suggestMultiple
(String gridId, String rowId, String columnId, boolean clear, String search, String label) Suggest or select multiple element which contains labelprotected void
suggestMultiple
(String gridId, String columnId, String search, String label) Suggest or select multiple element which contains labelprotected void
Suggest or select multiple element which contains labelprotected void
suggestMultipleList
(String criterionName, String... items) Suggest or select multiple element which contains labelprotected void
suggestResult
(String match) Select suggest result on suggest listprotected void
waitForButton
(String buttonName) Wait for button to be clickableprotected void
waitForContextButton
(String buttonName) Wait for context button to be clickableprotected org.openqa.selenium.By
waitForCssSelector
(String cssSelector) Wait for css selectorprotected void
waitForEmptyText
(org.openqa.selenium.By selector, String text) Wait for no text in selectorprotected void
Wait for loading bar to hideprotected void
Wait for loading grid to hideprotected void
waitForTab
(String tabCriterionName) Wait for tab to be clickableprotected void
waitForText
(String clazz, String contains) Wait for text inside a tag with a CSS classprotected void
waitForText
(org.openqa.selenium.By selector, String contains) Wait for text inside a tag with a CSS classprotected void
waitForValue
(org.openqa.selenium.By selector, String contains) Wait for text inside a tag with a CSS classprotected void
writeText
(String criterionName, CharSequence text) Write text on criterionprotected void
writeText
(String criterionName, CharSequence text, boolean clearText) Write text check clear textprotected void
writeText
(String gridId, String columnId, CharSequence text) Write text check clear textprotected void
writeText
(String gridId, String rowId, String columnId, CharSequence text) Write text check clear textprotected void
writeText
(String gridId, String rowId, String columnId, CharSequence text, boolean clearText) Write text check clear textprotected void
writeText
(org.openqa.selenium.By selector, CharSequence text) Write text on selectorprotected void
writeTextOnDriver
(org.openqa.selenium.By selector, CharSequence... text) Type keys on a criterion
-
Constructor Details
-
SeleniumUtilities
public SeleniumUtilities()
-
-
Method Details
-
getDriver
public org.openqa.selenium.WebDriver getDriver()Get driver- Specified by:
getDriver
in interfaceIAweInstructions
- Returns:
- Get driver
-
getBaseUrl
Get base URL- Returns:
- Get base URL
-
setSeleniumModel
Store selenium model- Specified by:
setSeleniumModel
in interfaceIAweInstructions
- Parameters:
model
- Selenium model
-
setTestTitle
Set test title- Parameters:
title
- Test title
-
gotoScreen
Go to a screen defined on the menu- Parameters:
menuOptions
- Menu options to navigate to
-
waitForCssSelector
Wait for css selector- Parameters:
cssSelector
- CSS Selector
-
waitForLoadingBar
protected void waitForLoadingBar()Wait for loading bar to hide -
waitForLoadingGrid
protected void waitForLoadingGrid()Wait for loading grid to hide -
waitForButton
Wait for button to be clickable- Parameters:
buttonName
- Button name
-
waitForTab
Wait for tab to be clickable- Parameters:
tabCriterionName
- Tab criterion name
-
waitForContextButton
Wait for context button to be clickable- Parameters:
buttonName
- Button name
-
waitForText
Wait for text inside a tag with a CSS class- Parameters:
clazz
- CSS classcontains
- Text to check
-
waitForText
Wait for text inside a tag with a CSS class- Parameters:
selector
- Selectorcontains
- Text to check
-
waitForValue
Wait for text inside a tag with a CSS class- Parameters:
selector
- Selectorcontains
- Text to check
-
waitForEmptyText
Wait for no text in selector- Parameters:
selector
- Selectortext
- Text to check
-
pause
Pause- Parameters:
time
- Milliseconds
-
click
Click on an element- Parameters:
cssSelector
- Input selector
-
clickButton
Click on a button- Parameters:
buttonName
- Button name
-
clickButton
Click on a button- Parameters:
buttonName
- Button namewaitForLoadingBar
- Wait for loading bar after clicking
-
clickContextButton
Click on a context button- Parameters:
contextButtonOptionList
- Context button option list
-
clickTab
Click on tab- Parameters:
tabName
- Tab nametabLabel
- Tab label local
-
clickInfoButton
Click on info button- Parameters:
infoButtonName
- Button name
-
clickTreeButton
Click on tree button- Parameters:
gridId
- Grid idrowId
- Row id
-
clickDate
Click on datepicker- Parameters:
criterionName
- Datepicker name
-
clickDate
Click on datepicker on grid- Parameters:
gridId
- Grid idcolumnId
- Column id
-
clickDate
Click on datepicker on grid- Parameters:
gridId
- Grid idrowId
- row idcolumnId
- Column id
-
selectDate
Select a date in datepicker- Parameters:
dateName
- Datepicker namedateValue
- Date to select
-
selectDate
Select a date in a grid- Parameters:
gridId
- Grid idcolumnId
- Column iddateValue
- Date to select
-
selectDate
Select a date in a grid- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column iddateValue
- Date to select
-
selectDay
Select a day in datepicker (current month)- Parameters:
dateName
- Datepicker nameday
- Day to select
-
selectDay
Select a day in datepicker (current month) in a grid- Parameters:
gridId
- Grid idcolumnId
- Column idday
- Day to select
-
selectDay
Select a day in datepicker (current month) in a grid- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idday
- Day to select
-
getTodayDay
Retrieve today day of month- Returns:
- Day of month as string
-
getTomorrowDay
Retrieve today day of month- Returns:
- Day of month as string
-
selectMonth
Select a month in datepicker- Parameters:
dateName
- Datepicker namemonth
- Month to select
-
selectMonth
Select a month in datepicker in a grid- Parameters:
gridId
- Grid idcolumnId
- Column idmonth
- Month to select
-
selectMonth
Select a month in datepicker in a grid- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idmonth
- Month to select
-
selectYear
Select a year in datepicker- Parameters:
dateName
- Datepicker nameyear
- Year to select
-
selectYear
Select a year in datepicker in a grid- Parameters:
gridId
- Grid idcolumnId
- Column idyear
- Year to select
-
selectYear
Select a year in datepicker in a grid- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idyear
- Year to select
-
clickCheckbox
Click on a checkbox or a radio button- Parameters:
criterionName
- Criterion name
-
clickCheckbox
Click on a checkbox or a radio button- Parameters:
gridId
- Grid idcolumnId
- Column id
-
clickCheckbox
Click on a checkbox or a radio button- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column id
-
clickRowContents
Click on row with a text- Parameters:
search
- Text to search
-
clickRowContents
Click on row with a text- Parameters:
gridId
- Grid to search insearch
- Text to search
-
editRow
Click on row with a text- Parameters:
search
- Text to search
-
editRow
Click on row with a text- Parameters:
gridId
- Grid to search insearch
- Text to search
-
editRow
Click on row- Parameters:
gridId
- Grid to search inrowId
- Row identifiercolumnId
- Column identifier
-
clickCell
Click on a cell on selected row- Parameters:
gridId
- Grid idcolumnId
- Column id
-
clickCell
Click on a grid cell- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column id
-
contextMenuRowContents
Context menu on row- Parameters:
search
- Text to search
-
contextMenuRowContents
Context menu on row- Parameters:
gridId
- Grid identifiersearch
- Text to search
-
contextMenu
Context menu on a grid- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column id
-
writeTextOnDriver
Type keys on a criterion- Parameters:
selector
- Criterion selector to type keystext
- Text to type
-
writeText
Write text on selector- Parameters:
selector
- Selectortext
- Text
-
writeText
Write text on criterion- Parameters:
criterionName
- Criterion nametext
- Text
-
writeText
Write text check clear text- Parameters:
criterionName
- Criterion nametext
- TextclearText
- Clear text
-
writeText
Write text check clear text- Parameters:
gridId
- Grid idcolumnId
- Column idtext
- Text to write
-
writeText
Write text check clear text- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idtext
- Text to write
-
writeText
protected void writeText(String gridId, String rowId, String columnId, CharSequence text, boolean clearText) Write text check clear text- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idtext
- Text to writeclearText
- Clear previous text
-
clearText
Clear text on input selector- Parameters:
cssSelector
- Input selector
-
getText
Get criterion text- Parameters:
criterionName
- Criterion name- Returns:
- Text from criterion
-
getText
Get selected row cell text- Parameters:
gridId
- Grid idcolumnId
- Column id- Returns:
- Cell text
-
getText
Get grid cell text- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column id- Returns:
- Cell text
-
selectFirst
Select first value of the select- Parameters:
criterionName
- Criterion name
-
selectFirst
Select first value of the select- Parameters:
gridId
- Grid idcolumnId
- Column id
-
selectFirst
Select first value of the select- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column id
-
selectLast
Select first value of the select- Parameters:
criterionName
- Criterion name
-
selectLast
Select first value of the select- Parameters:
gridId
- Grid idcolumnId
- Column id
-
selectLast
Select first value of the select- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column id
-
selectContain
Select value on the selector- Parameters:
criterionName
- Criterion namelabel
- Label to search
-
selectContain
Select value on the selector- Parameters:
gridId
- Grid idcolumnId
- Column idlabel
- Label to search
-
selectContain
Select value on the selector- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idlabel
- Label to search
-
selectAllRowsOfGrid
Select all rows of grid- Parameters:
gridId
- Grid id
-
selectResult
Select result on select list- Parameters:
match
- Match label
-
suggestResult
Select suggest result on suggest list- Parameters:
match
- Match label
-
suggest
Suggest element which contains label- Parameters:
criterionName
- Criterion namesearch
- Search stringlabel
- Label to search
-
suggest
Suggest element which contains label- Parameters:
gridId
- Grid idcolumnId
- Column idsearch
- Search stringlabel
- Label to search
-
suggest
Suggest element which contains label- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idsearch
- Search stringlabel
- Label to search
-
suggestLast
Suggest element which contains label- Parameters:
criterionName
- Criterion namesearch
- Search string
-
suggestLast
Suggest element which contains label- Parameters:
gridId
- Grid idcolumnId
- Column idsearch
- Search string
-
suggestLast
Suggest element which contains label- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idsearch
- Search string
-
suggestMultipleList
Suggest or select multiple element which contains label- Parameters:
criterionName
- Criterion nameitems
- Items to add and search for
-
suggestMultiple
Suggest or select multiple element which contains label- Parameters:
criterionName
- Criterion namesearch
- Search stringlabel
- Text to find in label
-
suggestMultiple
Suggest or select multiple element which contains label- Parameters:
gridId
- Grid idcolumnId
- Column idsearch
- Search stringlabel
- Text to find in label
-
suggestMultiple
protected void suggestMultiple(String gridId, String rowId, String columnId, String search, String label) Suggest or select multiple element which contains label- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idsearch
- Search stringlabel
- Text to find in label
-
suggestMultiple
Suggest or select multiple element which contains label- Parameters:
criterionName
- Criterion namesearch
- Search stringlabel
- Text to find in label
-
suggestMultiple
protected void suggestMultiple(String gridId, String columnId, boolean clear, String search, String label) Suggest or select multiple element which contains label- Parameters:
gridId
- Grid idcolumnId
- Column idsearch
- Search stringlabel
- Text to find in label
-
suggestMultiple
protected void suggestMultiple(String gridId, String rowId, String columnId, boolean clear, String search, String label) Suggest or select multiple element which contains label- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idsearch
- Search stringlabel
- Text to find in label
-
searchAndWait
protected void searchAndWait()Click on search button (ButSch) and wait the grid to load -
searchAndWait
Click on search button and wait the grid to load- Parameters:
buttonName
- Button name
-
saveRow
protected void saveRow()Click on save row and wait -
saveRow
Click on save row and wait- Parameters:
gridId
- Grid with the save button
-
scrollGrid
Scroll grid- Parameters:
gridId
- Grid identifierhorizontal
- Horizontal scroll in pixelsvertical
- Vertical scroll in pixels
-
showMouse
protected void showMouse()Show mouse -
sortGrid
Click on column header- Parameters:
gridId
- Grid identifiercolumnId
- Column identifier
-
acceptConfirm
protected void acceptConfirm()Accept confirm window and wait for it to disappear -
checkAndCloseMessage
Check a message box and close it- Parameters:
messageType
- Message type (success (default), info, warning, danger)
-
clickButtonAndConfirm
Click on confirm button, accept confirmation and accept message- Parameters:
button
- Button name
-
clickButtonAndConfirm
Click on confirm button, accept confirmation and accept message- Parameters:
button
- Button namemessageType
- Message type (info, warning, success, danger)
-
checkText
Check text inside css selector- Parameters:
cssSelector
- Selector to checktext
- Text to compare
-
checkTextContains
Check text inside css selector- Parameters:
cssSelector
- Selector to checktext
- Text to compare
-
checkTextNotContains
heck if selector doesn't contain a text- Parameters:
cssSelector
- Selector to checktext
- Text to compare
-
checkRowContents
Check if grid contains some texts- Parameters:
searchList
- Texts to search for in the grid
-
checkRowContentsGrid
Check if grid contains some texts- Parameters:
gridId
- Grid IdentifiersearchList
- Texts to search for in the grid
-
checkCellContents
Check cell contents- Parameters:
gridId
- Grid idrowId
- Row idcolumnId
- Column idsearch
- Search value
-
checkRowNotContains
Check if grid doesn't contain some texts- Parameters:
search
- Texts to search for in the grid
-
checkCriterionContents
Assert if a criterion contains a text- Parameters:
criterionName
- Criterion namesearch
- Text to check
-
checkCheckboxRadio
Assert if some criteria are checked or not- Parameters:
isChecked
- Flag to checkcriteriaNames
- Elements to check
-
checkSelectContents
Assert if a selector contains a text- Parameters:
criterionName
- Selector namesearch
- Text to check
-
checkSuggestContents
Assert if a suggest contains a text- Parameters:
criterionName
- Selector namesearch
- Text to check
-
checkSelectNumberOfResults
Assert if a selector contains a number of results- Parameters:
criterionName
- Selector namenumber
- Number of results to check
-
checkMultipleSelectorContents
Assert if a selector contains a text- Parameters:
criterionName
- Selector namesearch
- Text to check
-
checkMessageMissing
Check if message is missing- Parameters:
messageType
- Message type
-
checkPresence
Check element is present- Parameters:
cssSelector
- CSS selector
-
checkVisible
Check element is visible- Parameters:
cssSelector
- CSS selector
-
checkVisible
protected void checkVisible(org.openqa.selenium.By selector) Check element is visible- Parameters:
selector
- Selector
-
checkVisibleAndContains
Check element is visible- Parameters:
cssSelector
- CSS selectorsearch
- Search string
-
checkNotVisible
Check element is not visible- Parameters:
cssSelector
- CSS selector
-
checkNotVisible
protected void checkNotVisible(org.openqa.selenium.By selector) Check element is not visible- Parameters:
selector
- selector
-
goToUrl
Starting point; Go to a determined url- Parameters:
url
- Start url
-
checkLogin
Log into the application- Parameters:
username
- User namepassword
- PasswordcssSelector
- Selector to checkcheckText
- Text to check inside selector
-
checkLogout
Log out the application- Parameters:
cssSelector
- Selector to checkcheckText
- Text to check inside selector
-
selectModule
Select module in module list- Parameters:
moduleName
- Module name
-
broadcastMessageToUser
Broadcast a message to a user- Parameters:
user
- User nametext
- Text to send
-