Skip to content
QiTASC.com / UI Steps Language for Web and Apptests /
Defining Stepdefs in UI Steps
/ .. /
Defining Stepdefs in UI Steps





Defining Stepdefs in UI Steps

This section provides specific examples of using Stepdefs in UI Steps. For a general overview of step definitions, including parameter descriptions, use the Stepdefs section.

UI Steps Logic

In a simplified version of a UI Steps, including only a single Stepdef and View, the link between Actions and Elements can be visualized as follows:

alt text

In the UI Steps, a Stepdef calls the action of a View. An action defines the action performed on the element of the webpage.

UI Steps Example

In the following example, a Stepdef has been created to include a parameter for a search term, indicated by the curly brackets. The search term is then typed into the specified element, in this case the Google search bar with the ID lst-ib.

Stepdef Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
stepdef "enter searchstring {} on google" / stepSearchString /
    myView := open MyGoogle
    delay(2)
    // Add 2 seconds delay before executing the next command line.
    GoogleModel.performSearch(stepSearchString)
end

view MyGoogle
    url "http://www.google.at"
    elem searchField  := "//*[@id='lst-ib']"
    // The id of the google searchbar is "lst-ib".
    action (searchField)  defineSearchText := type
    action (searchField)  clearSearchText  := clear
    action (searchField)  doSearch         := submit
end

model GoogleModel
    func performSearch(stepSearchString)
        myView := await MyGoogle
        delay(2)
        myView.defineSearchText(stepSearchString)
        delay(2)
        myView.doSearch()
        delay(2)
        myView.clearSearchText()
    end
end

The Mygoogle View contains the definitions of the View's URL and the UI Steps Elements and Actions.