UI Steps Test Case Example
The following example describes the functionality using a UI Steps test case, comprised of its Feature File, Stepdefs, Models and Functions and Views.
Feature File
1
2
3
4
5
6
7
8
9
10
11
12
13 | Feature: UI Steps
Scenario Outline: UI Steps
Given a chrome browser as myBrowser
And on myBrowser open homepage and fill out form with car type
<carType> and text <freeText>
And on f1, query form entries
Then verify web.selectedCar == <carType>
Then verify web.enteredText == <freeText>
Then verify web.checkedBox == "yes"
Examples:
| carType | freeText |
| "saab" | "new model" |
| "suzuki" | "old model" |
|
Stepdefs
| stepdef "open homepage and fill out form with car type {}
and text {}" / carType, text /
newView := open form_Home
formHome.fillForm(carType, text)
end
stepdef "query form entries"
echoHome.readSelect()
echoHome.readText()
echoHome.readBox()
end
|
Models and Functions
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
28
29
30
31
32
33
34
35
36
37 | model formHome
func awaitForm()
formView := await form_Home
return formView
end
func fillForm(carType, text)
formView := awaitForm()
formView.selectField(carType)
formView.clearText()
formView.typeText(text)
formView.checkBox()
formView.clickButton()
end
end
model echoHome
func awaitEcho()
echoView := await echo_Home
return echoView
end
func readSelect()
echoView := echoHome.awaitEcho()
setContextObject("selectedCar", echoView.readSelectField())
end
func readText()
echoView := echoHome.awaitEcho()
setContextObject("enteredText", echoView.readTextField())
end
func readBox()
echoView := echoHome.awaitEcho()
setContextObject("checkedBox", echoView.readBoxField())
end
end
|
Views
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | view form_Home
url "http://www.web.com/form.html"
elem Select := "html/body/form/p[1]/select" [visible]
elem Text := "html/body/form/p[2]/textarea" [visible]
elem Check := "html/body/form/p[3]/input" [visible]
elem Click := "html/body/form/p[4]/input[2]" [visible]
action (Select) selectField := select
action (Text) clearText := clear
action (Text) typeText := type
action (Check) checkBox := check
action (Click) clickButton := click
end
view echo_Home
elem checkSelect := "html/body/table/tbody/tr[1]/td" [visible]
elem checkText := "html/body/table/tbody/tr[2]/td/tt" [visible]
elem checkBox := "html/body/table/tbody/tr[3]/td" [visible]
action (checkSelect) readSelectField := content
action (checkText) readTextField := content
action (checkBox) readBoxField := content
end
|