Skip to main content

Cucumber Test Automation - Steps Definition

Basic Steps

Press a button

Press a button with a given label on the current page

Parameters

  • Button Label : Label of the button must be an exact match.

E.g.: To press Sales button, you need to pass "Sales". Passing "sales" as button label will fail the test.

// Step definition
user presses "[Button Label]" button
 
// Usage
Given user presses "Sales" button  //press Sales button on POS

Press an Icon button

Press an icon button on the current page.

E.g.: top panel buttons (Home, CRM, Log out, etc…)

Parameters

  • Button Name : Name of the button. Button's component ID must be in the Client property file.

E.g.: to press 'LOG OUT' top panel button. 

Client property file : COMPONENT_LOG_OUT_BUTTON=LogOutButton

You can press this button by calling it "Log Out Button"

// Step definition
user presses "[Button Name]" icon button
 
// Usage
Given user presses "Log Out Button" icon button  //press Log out top panel button on POS

Press a button and check another page displays

Press a button with a given label and check another page displays

Parameters

  • Button Label : Label of the button must be an exact match.

E.g.: To press Sales button, you need to pass "Sales". Passing "sales" as button label will fail the test.

  • Window Name
// Step definition
user presses "[Button Label]" button and "[Window Name]" page shown
 
// Usage
When user presses "TOTAL" button and "Select Tender" page shown  //press Total button on POS and check select tender screen display

Enter text into a field

Enter text into a text field in the current page.

Parameters

  • text: value you want to enter into the text field
  • Component Name
// Step definition
user enters "[text]" into "[Component Name]" field
 
// Usage
Given user enters "1001000" into "Input Box" field  //enter product id into input box text field

Verify text field value

Verify current page text field value.

Parameters

  • text: value you want to verify

  • Component Name

// Step definition
"[Component Name]" field displays the text "[text]"
 
// Usage
Then "Gift Card Status" field displays the text "Active"

Check page display

Checks page/screen display

Parameters

  • Window Name
// Step definition
"[Window Name]" page is shown
 
// Usage
Then "Transaction Basket" page is shown  //check transaction basket screen display

Select item from a selection list 

Select a given item from a selection list on the current page

Parameters

  • Item : value you want to select from selection list.

  • Component Name

// Step definition
user selects "[Item]" from "[Component Name]" list
 
// Usage
And user selects "Operator Error" from "Selection List" list  //select void reason from reason list

Select/Unselect check-box 

Select and Unselect check-box on the current page

Parameters

  • Component Name
// Step definition
user presses "[Component Name]" checkbox
 
// Usage
And user presses "Card Inserted" checkbox

Check item display in a selection list

Check item display in a list on the current page

Parameters

  • Item : value you want to check displayed in the selection list.

  • Component Name

// Step definition
"[Item]" display in "[Component Name]" list
 
// Usage
And "Product 1 Description" display in "Receipt" list  //check item display in the basket

Check item NOT display in a selection list

Check item NOT displayed in a list on the current page

Parameters

  • Item : the value you want to check NOT displayed in the selection list.

  • Component Name

// Step definition
"[Item]" is not displayed in "[Component Name]" list
 
// Usage
And "Promotion" is not displayed in "Receipt" list  //check item not displayed in the basket

Verify text value on a panel

Check text displayed in a given panel on the current page

Parameters

  • Text : the value you want to check displayed in the panel component

  • Component Name

// Step definition
"[Text]" is displayed in "[Component Name]" panel
 
// Usage
And "${Customer 1 Full Name}" is displayed in "CRM Customer Client Details Page Personal Details Section" panel

Verify text value on a label

Check text displayed in a given label on the current page

Parameters

  • Text : the value you want to check displayed in the label component

  • Component Name

// Step definition
"[Component Name]" label displays the text "[Text]"
 
// Usage
And "Basket Total" label displays the text "£10.00"

Select item from a combo box

Select item from combo box on the current page

Parameters

  • Item : item you want to select from combo box.

  • Component Name

// Step definition
user selects "[Item]" option from "[Component Name]" combobox
 
// Usage
And user selects "Mr" option from "Customer Title Dropdown" combobox  //select Mr option from customer title dropdown box

Check item NOT display

confirms component NOT display on current page

Parameters

  • Component Name
// Step definition
user confirms "[Component Name]" not display
 
// Usage
And user confirms "Product Search Button" not display

Login as a given user

You can use this step to login to the pos as given user instead of entering Username, Password and press Enter button. This will check

  1. login page display

  2. if login page display then enter username and password

  3. then press enter button

  4. then wait until Basket screen display

Parameters

  • user : given name for user.

if you want to login as Sales Assistant, then you need to specify user's username and password in test data property file in following format

[ User's given name ]_USERNAME=[ Username ]     eg:- SALES_ASSISTANT_USERNAME=1010

[ User's given name ]_PASSWORD=[ Password ]     eg:- SALES_ASSISTANT_PASSWORD=1010

// Step definition
user signs on as "[User Given Name]"
 
// Usage
Given user signs on as "Sales Assistant"

Advance Steps

Check text display on the receipt 

Check given text display in test printer window

Parameters

  • data table : all items you want to check in the receipt
// Step definition
receipt display with following details
|[key]|[value]|
 
// Usage
And receipt display with following details
        | address   | Enactor House,1 Bluecoats,Hertford,Hertfordshire,SG14 1PB |
        | telephone | Tel: 01992 500881                                         |
        | text      | Customer:  Cust_Forename Cust_Surname                     |
        | item      | Product 2 Description,£10.00                              |

Check text NOT display on the receipt 

Check given text is NOT display in test printer window

Parameters

  • data table : all items you want to check in the receipt
// Step definition
following details are not displayed on the receipt
|[key]|[value]|
 
// Usage
And following details are not displayed on the receipt 
        | text      | Customer:  Cust_Forename Cust_Surname                     |
        | item      | Product 2 Description,£10.00                              |

Press a button on a test peripheral

Press a button with a given label on test peripheral window. ie: Test Cash Drawer window, Test ICC Reader window etc.

Parameters

  • Button Label : Label of the button must be exact match.

eg: To press Sales button, you need to pass "Sales". Passing "sales" as button label will fail the test.

  • Window Name
// Step definition
user presses "[Button Label]" button on test "[Window Name]" window
 
// Usage
When user presses "Close" button on test "Cash Drawer" window  //press Close button on test cash drawer window

Wait for a component to display 

User waits for a component to display on the current page

Parameters

  • Component Name
// Step definition
user waits "[Component Name]" to display
 
// Usage
And user waits "Product Search Result Item 1" to display

Wait for x number of seconds  

User waits for x number of seconds

Parameters

  • Number of Seconds
// Step definition
user waits "[No. of Seconds]" seconds
 
// Usage
And user waits "2" seconds

Block URI connection

Block connection to the given URI

Parameters

  • URI:
// Step definition
the pos blocks connections to '(.+)'
 
// Usage
When the pos blocks connections to "http://localhost:8082"

Unblock URI connection

Unblock connection to the given URI

Parameters

  • URI:
// Step definition
the pos unblocks connections to '(.+)'
 
// Usage
When the pos unblocks connections to "http://localhost:8082"

Additional Steps

Submit an item to the basket 

This is to add an item i.e product, giftcard, etc. to the basket. This will enter the given item into the input text field and press 'ENT' button

Parameters

  • Item
// Step definition
user submits "(.+)" on the basket
 
// Usage
And user submits "2" on the basket
And user submits "${Product 1}" on the basket

Complete transaction by CASH tender 

This is to complete a transaction by CASH tender. This step will perform the followings actions

  1. press Total button

  2. press Cash button (select tender screen)

  3. Press OK button (cash amount screen)

  4. Press Close button on Cash Drawer window

  5. Check Transaction Basket display

*Note : this step can't be used if customer signature verification required during the tender*

// Step definition
user completes the transaction by cash tender
 
// Usage
And user completes the transaction by cash tender

Window Inspector

Many of the methods on this API will require the window ID or component ID that the method should operator on. This can be found by running the POS through the AUT controller and then using the following key combination:

SHIFT + ALT + Right Mouse Button

When the Right Mouse Button is clicked, output similar to the following should appear on the console of the POS:

Active Window - Name: Point-of-Sale Application:Point-of-Sale Application:Enter User  Pos/SignOn/SignOn  EnterUserState  Pos/SignOn/EnterUser
Component Clicked - Name: InputBox

In this example, the id of the window is ‘Point-of-Sale Application:Point-of-Sale Application:Enter User  Pos/SignOn/SignOn  EnterUserState  Pos/SignOn/EnterUser’

and the id of the component is ‘InputBox’

Using Property Files in the POS setup

Client Property File

Window details 

The window name can be found by inspecting the page (refer to Window Inspector section for more details).

Window details defined in following format in client property file:

[Window Name]=[Window Id]

Window name starts with prefix WINDOW_ and name of the window is all uppercase and replace spaces with _ (underscore)

E.g. :  WINDOW_SELECT_TENDER=Point-of-Sale Application:Point-of-Sale Application:Select Tender Pos/Tender/DoTender SelectTender NextGen1024x768/Pos/Tender/SelectTender

To use this window, you can pass "Select Tender" as window name from your cucumber step

Pop up Windows and Prompts

There is a special condition when it comes to pop-up windows and prompts. When defining the component ID for these windows, make sure to add the prefix \ (backslash and two spaces) before the actual component ID.

E.g.:

WINDOW_DAY_START_ACKNOWLEDGE_PROMPT=\  Pos/Status/InteractiveDayStart  AcknowledgeComplete  NextGen1024x768/Message/PopUpModalOK
WINDOW_UNKNOWN_PRODUCT_NOT_ALLOWED=\ Pos/Product/SellUnknownProductDataCapture UnknownProductNotAllowed NextGen1024x768/ErrorMessage/ModalOK

Component details 

Component ID can be found by inspecting component (refer to Inspect Window section in POS Automation Testing for more details). Component details defined in following format in client property file.

COMPONENT_INPUT_BOX=InputBox
COMPONENT_RECEIPT=Receipt
COMPONENT_BUTTON_1=Button1
COMPONENT_BUTTON_2=Button2
COMPONENT_BUTTON_3=Button3

Component name starts with prefix COMPONENT_ and name of the component is all uppercase and replace spaces with _ (underscore).

E.g. : COMPONENT_INPUT_BOX=InputBox

To use this component, you can pass "Input Box" as component name from your cucumber step.

Data Property File

Instead of directly giving the values to cucumber steps, you can tell step to pick data from data file by wrapping data in \${ [data] }.

// enter product id 1 into input box field
Given user enters "1" into "Input Box" field
 
// to get the value 1 from data file
Given user enters "${Product 1}" into "Input Box" field

In data property file, create an entry with same name given to data in cucumber step (eg: Product 1). Change the name all uppercase and replace spaces with _ (underscore)

//All uppercase and replace spaces with _ (underscore)
PRODUCT_1=1

Using Property Files in the EM setup

Using the enactorSelenium.properties file

The parameter should be named with dot separated value.

eg: If the page name is Product Sales the parameter and the related value should be as fellows.

HomePage.label.product.sales=Product Sales

Using the TestData.properties file

The parameter value should be mentioned as follows if the value mentioned in the script is as "\${Style Size Product 1}"

eg:

And the user enters "\${Style Size Product 1}" into the "Product ID Filter" input field

Value in the TestData.properties file

style.size.product.1=A-5

POS Cucumber Scripts

POS Cucumber Steps

1.  Given user signs on as " "
 
2.  When user presses " " button 
 
3.  Then " " page is shown 
 
4.  When user presses " " button and " " page shown
 
5.  When user presses " " icon button 
 
6.  When user selects " " from " " list
 
7.  When user selects " " from " " combobox
 
8.  Then " " is displayed in " " list
 
9.  Then " " is not displayed in " " list
 
10. When user enters " " into " " field 
 
11. When user presses " " button on external " " window
 
12. When user presses " " checkbox
 
13. Then " " is displayed in " " panel
 
14. Then " " field displays the text " "
 
15. And user waits " " to display
 
16. And user confirms " " not display
 
17. Then receipt display with following details
        | address         | <text to verify>        |
        | telephone       | <text to verify>        |
        | item            | <text to verify>        |
        | item flag       | <text to verify>        |
        | gift card type  | <text to verify>        |
        | gift card number| <text to verify>        |
        | text            | <text to verify>        |
 
18. Then following details are not displayed on the receipt
        | address         | <text to verify>        |
        | telephone       | <text to verify>        |
        | item            | <text to verify>        |
        | gift card type  | <text to verify>        |
        | gift card number| <text to verify>        |
        | text            | <text to verify>        |
 
19. When the pos blocks connections to " "
 
20. And the pos unblocks connections to " "
 
21. Given View data of type String with name "" and value "" is set (Introduced by PLAT-19827)
   
22. And View data of type Long with name "" and value "" is set (Introduced by PLAT-19827)

Web Cucumber Scripts

Web Cucumber Steps

1.  When user login and navigates to the \"(.*)\" app
 
2.  When user presses launch bar " " button
 
3.  When user presses " " button
 
4.  Then "^\"(.*)\" field error is shown
 
5.  Then "^\"(.*)\" page error is shown
 
6.  Then "^\"(.*)\" text field is display
 
7.  Then searched item not shown in the search result table
        | <column name>         | <column value>        |
 
8.  Then searched item shown in the search result table
        | <column name>         | <column value>        |
 
9.  When user clicks on \"(.*)\" link button of the search result item
 
10. Then "^\"(.*)\" page is shown with \"(.*)\" button
 
11. Then "^\"(.*)\" page is shown with \"(.*)\" text field
 
12. Then "^\"(.*)\" page is shown in \"(.*)\" mode
 
13. When user enters " " into " " input field
 
14. When user selects \"(.*)\" from \"(.*)\" dropdown field
 
15. Then "^\"(.*)\" text is shown in the \"(.*)\" text field
 
16. Then "^\"(.*)\" text is shown in the \"(.*)\" dropdown field
 
17. When user clicks ok of the confirmation
 
18. Then "^\"(.*)\" field is disabled
 
19. Given Web Maintenance launched from \"(.*)\" device
 
20. Then a confirmation message with text \"(.*?)\" is shown
 
21. Then checkBox \"(.*?)\" is selected
 
22. Then user clicks \"(.*?)\" tab
 
23. When user selects \"(.*?)\" check box