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 Details

    • SeleniumUtilities

      public SeleniumUtilities()
  • Method Details

    • getDriver

      public org.openqa.selenium.WebDriver getDriver()
      Get driver
      Specified by:
      getDriver in interface IAweInstructions
      Returns:
      Get driver
    • getBaseUrl

      public String getBaseUrl()
      Get base URL
      Returns:
      Get base URL
    • setSeleniumModel

      public IAweInstructions setSeleniumModel(SeleniumModel model)
      Store selenium model
      Specified by:
      setSeleniumModel in interface IAweInstructions
      Parameters:
      model - Selenium model
    • setTestTitle

      protected void setTestTitle(String title)
      Set test title
      Parameters:
      title - Test title
    • gotoScreen

      protected void gotoScreen(String... menuOptions)
      Go to a screen defined on the menu
      Parameters:
      menuOptions - Menu options to navigate to
    • waitForCssSelector

      protected org.openqa.selenium.By waitForCssSelector(String cssSelector)
      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

      protected void waitForButton(String buttonName)
      Wait for button to be clickable
      Parameters:
      buttonName - Button name
    • waitForTab

      protected void waitForTab(String tabCriterionName)
      Wait for tab to be clickable
      Parameters:
      tabCriterionName - Tab criterion name
    • waitForContextButton

      protected void waitForContextButton(String buttonName)
      Wait for context button to be clickable
      Parameters:
      buttonName - Button name
    • waitForText

      protected void waitForText(String clazz, String contains)
      Wait for text inside a tag with a CSS class
      Parameters:
      clazz - CSS class
      contains - Text to check
    • waitForText

      protected void waitForText(org.openqa.selenium.By selector, String contains)
      Wait for text inside a tag with a CSS class
      Parameters:
      selector - Selector
      contains - Text to check
    • waitForValue

      protected void waitForValue(org.openqa.selenium.By selector, String contains)
      Wait for text inside a tag with a CSS class
      Parameters:
      selector - Selector
      contains - Text to check
    • waitForEmptyText

      protected void waitForEmptyText(org.openqa.selenium.By selector, String text)
      Wait for no text in selector
      Parameters:
      selector - Selector
      text - Text to check
    • pause

      protected void pause(Integer time)
      Pause
      Parameters:
      time - Milliseconds
    • click

      protected void click(String cssSelector)
      Click on an element
      Parameters:
      cssSelector - Input selector
    • clickButton

      protected void clickButton(String buttonName)
      Click on a button
      Parameters:
      buttonName - Button name
    • clickButton

      protected void clickButton(String buttonName, boolean waitForLoadingBar)
      Click on a button
      Parameters:
      buttonName - Button name
      waitForLoadingBar - Wait for loading bar after clicking
    • clickContextButton

      protected void clickContextButton(String... contextButtonOptionList)
      Click on a context button
      Parameters:
      contextButtonOptionList - Context button option list
    • clickTab

      protected void clickTab(String tabName, String tabLabel)
      Click on tab
      Parameters:
      tabName - Tab name
      tabLabel - Tab label local
    • clickInfoButton

      protected void clickInfoButton(String infoButtonName)
      Click on info button
      Parameters:
      infoButtonName - Button name
    • clickTreeButton

      protected void clickTreeButton(String gridId, String rowId)
      Click on tree button
      Parameters:
      gridId - Grid id
      rowId - Row id
    • clickDate

      protected void clickDate(String criterionName)
      Click on datepicker
      Parameters:
      criterionName - Datepicker name
    • clickDate

      protected void clickDate(String gridId, String columnId)
      Click on datepicker on grid
      Parameters:
      gridId - Grid id
      columnId - Column id
    • clickDate

      protected void clickDate(String gridId, String rowId, String columnId)
      Click on datepicker on grid
      Parameters:
      gridId - Grid id
      rowId - row id
      columnId - Column id
    • selectDate

      protected void selectDate(String dateName, CharSequence dateValue)
      Select a date in datepicker
      Parameters:
      dateName - Datepicker name
      dateValue - Date to select
    • selectDate

      protected void selectDate(String gridId, String columnId, CharSequence dateValue)
      Select a date in a grid
      Parameters:
      gridId - Grid id
      columnId - Column id
      dateValue - Date to select
    • selectDate

      protected void selectDate(String gridId, String rowId, String columnId, CharSequence dateValue)
      Select a date in a grid
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      dateValue - Date to select
    • selectDay

      protected void selectDay(String dateName, @Nonnull Integer day)
      Select a day in datepicker (current month)
      Parameters:
      dateName - Datepicker name
      day - Day to select
    • selectDay

      protected void selectDay(String gridId, String columnId, @Nonnull Integer day)
      Select a day in datepicker (current month) in a grid
      Parameters:
      gridId - Grid id
      columnId - Column id
      day - Day to select
    • selectDay

      protected void selectDay(String gridId, String rowId, String columnId, @Nonnull Integer day)
      Select a day in datepicker (current month) in a grid
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      day - Day to select
    • getTodayDay

      protected Integer getTodayDay()
      Retrieve today day of month
      Returns:
      Day of month as string
    • getTomorrowDay

      protected Integer getTomorrowDay()
      Retrieve today day of month
      Returns:
      Day of month as string
    • selectMonth

      protected void selectMonth(String dateName, String month)
      Select a month in datepicker
      Parameters:
      dateName - Datepicker name
      month - Month to select
    • selectMonth

      protected void selectMonth(String gridId, String columnId, String month)
      Select a month in datepicker in a grid
      Parameters:
      gridId - Grid id
      columnId - Column id
      month - Month to select
    • selectMonth

      protected void selectMonth(String gridId, String rowId, String columnId, String month)
      Select a month in datepicker in a grid
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      month - Month to select
    • selectYear

      protected void selectYear(String dateName, @Nonnull Integer year)
      Select a year in datepicker
      Parameters:
      dateName - Datepicker name
      year - Year to select
    • selectYear

      protected void selectYear(String gridId, String columnId, @Nonnull Integer year)
      Select a year in datepicker in a grid
      Parameters:
      gridId - Grid id
      columnId - Column id
      year - Year to select
    • selectYear

      protected void selectYear(String gridId, String rowId, String columnId, @Nonnull Integer year)
      Select a year in datepicker in a grid
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      year - Year to select
    • clickCheckbox

      protected void clickCheckbox(String criterionName)
      Click on a checkbox or a radio button
      Parameters:
      criterionName - Criterion name
    • clickCheckbox

      protected void clickCheckbox(String gridId, String columnId)
      Click on a checkbox or a radio button
      Parameters:
      gridId - Grid id
      columnId - Column id
    • clickCheckbox

      protected void clickCheckbox(String gridId, String rowId, String columnId)
      Click on a checkbox or a radio button
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
    • clickRowContents

      protected void clickRowContents(String search)
      Click on row with a text
      Parameters:
      search - Text to search
    • clickRowContents

      protected void clickRowContents(String gridId, String search)
      Click on row with a text
      Parameters:
      gridId - Grid to search in
      search - Text to search
    • editRow

      protected void editRow(String search)
      Click on row with a text
      Parameters:
      search - Text to search
    • editRow

      protected void editRow(String gridId, String search)
      Click on row with a text
      Parameters:
      gridId - Grid to search in
      search - Text to search
    • editRow

      protected void editRow(String gridId, String rowId, String columnId)
      Click on row
      Parameters:
      gridId - Grid to search in
      rowId - Row identifier
      columnId - Column identifier
    • clickCell

      protected void clickCell(String gridId, String columnId)
      Click on a cell on selected row
      Parameters:
      gridId - Grid id
      columnId - Column id
    • clickCell

      protected void clickCell(String gridId, String rowId, String columnId)
      Click on a grid cell
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
    • contextMenuRowContents

      protected void contextMenuRowContents(String search)
      Context menu on row
      Parameters:
      search - Text to search
    • contextMenuRowContents

      protected void contextMenuRowContents(String gridId, String search)
      Context menu on row
      Parameters:
      gridId - Grid identifier
      search - Text to search
    • contextMenu

      protected void contextMenu(String gridId, String rowId, String columnId)
      Context menu on a grid
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
    • writeTextOnDriver

      protected void writeTextOnDriver(org.openqa.selenium.By selector, CharSequence... text)
      Type keys on a criterion
      Parameters:
      selector - Criterion selector to type keys
      text - Text to type
    • writeText

      protected void writeText(org.openqa.selenium.By selector, CharSequence text)
      Write text on selector
      Parameters:
      selector - Selector
      text - Text
    • writeText

      protected void writeText(String criterionName, CharSequence text)
      Write text on criterion
      Parameters:
      criterionName - Criterion name
      text - Text
    • writeText

      protected void writeText(String criterionName, CharSequence text, boolean clearText)
      Write text check clear text
      Parameters:
      criterionName - Criterion name
      text - Text
      clearText - Clear text
    • writeText

      protected void writeText(String gridId, String columnId, CharSequence text)
      Write text check clear text
      Parameters:
      gridId - Grid id
      columnId - Column id
      text - Text to write
    • writeText

      protected void writeText(String gridId, String rowId, String columnId, CharSequence text)
      Write text check clear text
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      text - 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 id
      rowId - Row id
      columnId - Column id
      text - Text to write
      clearText - Clear previous text
    • clearText

      protected void clearText(String cssSelector)
      Clear text on input selector
      Parameters:
      cssSelector - Input selector
    • getText

      protected String getText(String criterionName)
      Get criterion text
      Parameters:
      criterionName - Criterion name
      Returns:
      Text from criterion
    • getText

      protected String getText(String gridId, String columnId)
      Get selected row cell text
      Parameters:
      gridId - Grid id
      columnId - Column id
      Returns:
      Cell text
    • getText

      protected String getText(String gridId, String rowId, String columnId)
      Get grid cell text
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      Returns:
      Cell text
    • selectFirst

      protected void selectFirst(String criterionName)
      Select first value of the select
      Parameters:
      criterionName - Criterion name
    • selectFirst

      protected void selectFirst(String gridId, String columnId)
      Select first value of the select
      Parameters:
      gridId - Grid id
      columnId - Column id
    • selectFirst

      protected void selectFirst(String gridId, String rowId, String columnId)
      Select first value of the select
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
    • selectLast

      protected void selectLast(String criterionName)
      Select first value of the select
      Parameters:
      criterionName - Criterion name
    • selectLast

      protected void selectLast(String gridId, String columnId)
      Select first value of the select
      Parameters:
      gridId - Grid id
      columnId - Column id
    • selectLast

      protected void selectLast(String gridId, String rowId, String columnId)
      Select first value of the select
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
    • selectContain

      protected void selectContain(String criterionName, String label)
      Select value on the selector
      Parameters:
      criterionName - Criterion name
      label - Label to search
    • selectContain

      protected void selectContain(String gridId, String columnId, String label)
      Select value on the selector
      Parameters:
      gridId - Grid id
      columnId - Column id
      label - Label to search
    • selectContain

      protected void selectContain(String gridId, String rowId, String columnId, String label)
      Select value on the selector
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      label - Label to search
    • selectAllRowsOfGrid

      protected void selectAllRowsOfGrid(String gridId)
      Select all rows of grid
      Parameters:
      gridId - Grid id
    • selectResult

      protected void selectResult(String match)
      Select result on select list
      Parameters:
      match - Match label
    • suggestResult

      protected void suggestResult(String match)
      Select suggest result on suggest list
      Parameters:
      match - Match label
    • suggest

      protected void suggest(String criterionName, String search, String label)
      Suggest element which contains label
      Parameters:
      criterionName - Criterion name
      search - Search string
      label - Label to search
    • suggest

      protected void suggest(String gridId, String columnId, String search, String label)
      Suggest element which contains label
      Parameters:
      gridId - Grid id
      columnId - Column id
      search - Search string
      label - Label to search
    • suggest

      protected void suggest(String gridId, String rowId, String columnId, String search, String label)
      Suggest element which contains label
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      search - Search string
      label - Label to search
    • suggestLast

      protected void suggestLast(String criterionName, String search)
      Suggest element which contains label
      Parameters:
      criterionName - Criterion name
      search - Search string
    • suggestLast

      protected void suggestLast(String gridId, String columnId, String search)
      Suggest element which contains label
      Parameters:
      gridId - Grid id
      columnId - Column id
      search - Search string
    • suggestLast

      protected void suggestLast(String gridId, String rowId, String columnId, String search)
      Suggest element which contains label
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      search - Search string
    • suggestMultipleList

      protected void suggestMultipleList(String criterionName, String... items)
      Suggest or select multiple element which contains label
      Parameters:
      criterionName - Criterion name
      items - Items to add and search for
    • suggestMultiple

      protected void suggestMultiple(String criterionName, String search, String label)
      Suggest or select multiple element which contains label
      Parameters:
      criterionName - Criterion name
      search - Search string
      label - Text to find in label
    • suggestMultiple

      protected void suggestMultiple(String gridId, String columnId, String search, String label)
      Suggest or select multiple element which contains label
      Parameters:
      gridId - Grid id
      columnId - Column id
      search - Search string
      label - 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 id
      rowId - Row id
      columnId - Column id
      search - Search string
      label - Text to find in label
    • suggestMultiple

      protected void suggestMultiple(String criterionName, boolean clear, String search, String label)
      Suggest or select multiple element which contains label
      Parameters:
      criterionName - Criterion name
      search - Search string
      label - 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 id
      columnId - Column id
      search - Search string
      label - 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 id
      rowId - Row id
      columnId - Column id
      search - Search string
      label - Text to find in label
    • searchAndWait

      protected void searchAndWait()
      Click on search button (ButSch) and wait the grid to load
    • searchAndWait

      protected void searchAndWait(String buttonName)
      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

      protected void saveRow(String gridId)
      Click on save row and wait
      Parameters:
      gridId - Grid with the save button
    • scrollGrid

      protected void scrollGrid(String gridId, int horizontal, int vertical)
      Scroll grid
      Parameters:
      gridId - Grid identifier
      horizontal - Horizontal scroll in pixels
      vertical - Vertical scroll in pixels
    • showMouse

      protected void showMouse()
      Show mouse
    • sortGrid

      protected void sortGrid(String gridId, String columnId)
      Click on column header
      Parameters:
      gridId - Grid identifier
      columnId - Column identifier
    • acceptConfirm

      protected void acceptConfirm()
      Accept confirm window and wait for it to disappear
    • checkAndCloseMessage

      protected void checkAndCloseMessage(String messageType)
      Check a message box and close it
      Parameters:
      messageType - Message type (success (default), info, warning, danger)
    • clickButtonAndConfirm

      protected void clickButtonAndConfirm(String button)
      Click on confirm button, accept confirmation and accept message
      Parameters:
      button - Button name
    • clickButtonAndConfirm

      protected void clickButtonAndConfirm(String button, String messageType)
      Click on confirm button, accept confirmation and accept message
      Parameters:
      button - Button name
      messageType - Message type (info, warning, success, danger)
    • checkText

      protected void checkText(String cssSelector, String text)
      Check text inside css selector
      Parameters:
      cssSelector - Selector to check
      text - Text to compare
    • checkTextContains

      protected void checkTextContains(String cssSelector, String text)
      Check text inside css selector
      Parameters:
      cssSelector - Selector to check
      text - Text to compare
    • checkTextNotContains

      protected void checkTextNotContains(String cssSelector, String text)
      heck if selector doesn't contain a text
      Parameters:
      cssSelector - Selector to check
      text - Text to compare
    • checkRowContents

      protected void checkRowContents(String... searchList)
      Check if grid contains some texts
      Parameters:
      searchList - Texts to search for in the grid
    • checkRowContentsGrid

      protected void checkRowContentsGrid(String gridId, String... searchList)
      Check if grid contains some texts
      Parameters:
      gridId - Grid Identifier
      searchList - Texts to search for in the grid
    • checkCellContents

      protected void checkCellContents(String gridId, String rowId, String columnId, String search)
      Check cell contents
      Parameters:
      gridId - Grid id
      rowId - Row id
      columnId - Column id
      search - Search value
    • checkRowNotContains

      protected void checkRowNotContains(String search)
      Check if grid doesn't contain some texts
      Parameters:
      search - Texts to search for in the grid
    • checkCriterionContents

      protected void checkCriterionContents(String criterionName, String search)
      Assert if a criterion contains a text
      Parameters:
      criterionName - Criterion name
      search - Text to check
    • checkCheckboxRadio

      protected void checkCheckboxRadio(boolean isChecked, String... criteriaNames)
      Assert if some criteria are checked or not
      Parameters:
      isChecked - Flag to check
      criteriaNames - Elements to check
    • checkSelectContents

      protected void checkSelectContents(String criterionName, String search)
      Assert if a selector contains a text
      Parameters:
      criterionName - Selector name
      search - Text to check
    • checkSuggestContents

      protected void checkSuggestContents(String criterionName, String search)
      Assert if a suggest contains a text
      Parameters:
      criterionName - Selector name
      search - Text to check
    • checkSelectNumberOfResults

      protected void checkSelectNumberOfResults(String criterionName, Integer number)
      Assert if a selector contains a number of results
      Parameters:
      criterionName - Selector name
      number - Number of results to check
    • checkMultipleSelectorContents

      protected void checkMultipleSelectorContents(String criterionName, String search)
      Assert if a selector contains a text
      Parameters:
      criterionName - Selector name
      search - Text to check
    • checkMessageMissing

      protected void checkMessageMissing(String messageType)
      Check if message is missing
      Parameters:
      messageType - Message type
    • checkPresence

      protected void checkPresence(String cssSelector)
      Check element is present
      Parameters:
      cssSelector - CSS selector
    • checkVisible

      protected void checkVisible(String cssSelector)
      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

      protected void checkVisibleAndContains(String cssSelector, String search)
      Check element is visible
      Parameters:
      cssSelector - CSS selector
      search - Search string
    • checkNotVisible

      protected void checkNotVisible(String cssSelector)
      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

      protected void goToUrl(String url)
      Starting point; Go to a determined url
      Parameters:
      url - Start url
    • checkLogin

      protected void checkLogin(String username, String password, String cssSelector, String checkText)
      Log into the application
      Parameters:
      username - User name
      password - Password
      cssSelector - Selector to check
      checkText - Text to check inside selector
    • checkLogout

      protected void checkLogout(String cssSelector, String checkText)
      Log out the application
      Parameters:
      cssSelector - Selector to check
      checkText - Text to check inside selector
    • selectModule

      protected void selectModule(String moduleName)
      Select module in module list
      Parameters:
      moduleName - Module name
    • broadcastMessageToUser

      protected void broadcastMessageToUser(String user, String text)
      Broadcast a message to a user
      Parameters:
      user - User name
      text - Text to send