Skip to content
QiTASC.com / UI Steps Language /
Additional Language Elements in UI Steps
/ .. /
Additional Language Elements...





Additional Language Elements in UI Steps

In addition to the language features described in the Vocable Expression and Statement Language chapters, the UI Steps layer contains additional expressions that can be used with Views.

Statements

Open Statement

The open statement can be used in UI Steps to open a string representing a URL without the need for a surrounding View.

Syntax

1
open <url String>

Parameter

  • url - The URL to be opened

Example

1
2
3
4
5
6
7
8
9
stepdef "open google"
    myModel.openUrl()
end

model myModel
    func openUrl()
        open "http://www.google.com"
    end
end

Feature File Example

1
2
3
4
5
6
7
Feature: open without view

    Scenario: open without view

        And open browser chrome as b
        And on b, open google
        And wait for 10 seconds

On Detect Listeners

There are times when unpredictable elements like promotions or notifications that pop up and block the current view. These elements are not usually part of the regular test flow, so intaQt provides on-detect actions to deal these pop-ups. If a view as such, pops up, intaQt automatically performs an action that you define, and closes the pop-up. This eliminates the need to handle such pop-ups with every interaction of the web page or app under test.

The on detect listener automatically executes a function when a View is detected when using: Find, Await or Open expressions. For example, closing a pop-up window.

Important! The target View must not have parameters.

Syntax

1
on detect := <model Name>::<function Identifier>

Parameters

  • model - The model that contains the closeFunction function

  • function - The function executed on the detected View

The following example uses the on detect expression to automatically detect a predefined dialog window. While the openDetectView View contains an Element to open a dialog window, the dialogView automatically detects the dialog window and subsequently closes it with the closeit() function.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
stepdef "close modal dialog and verify it is not visible any more"

    v := open MainView
    v.clickToOpenDialog()
    v := await MainView

    delay(2)
    v.clickTryButton()
    delay(2)
    Page.goBack()
    delay(2)

    // Verifies that the dialog window is not a part of the view anymore
    v := find dialogBeGoneView
    assert v != null

end

view MainView
url "https://www.w3schools.com/howto/howto_css_modals.asp"
    elem button := ".//*[@id='main']/button" [visible]
    elem NextButton := "//*[@id='main']/div[2]/a[2]" [visible]

    action (button) clickToOpenDialog := click
    action (NextButton) clickTryButton := click
end

view dialogView
    elem closeButton := ".//*[@id='id01']/div/header/span" [visible]
    action (closeButton) closeIt := click
    on detect := MyModel::closeDialog
end

view dialogBeGoneView
    url "https://www.w3schools.com/howto/howto_css_modals.asp"
    elem button := ".//*[@id='main']/button" [visible]
    action (button) clickToOpenDialog := click
end

model MyModel
    func closeDialog(v)
        delay(2)
        v.closeIt()
    end
end

Expressions

The following expressions can be used within Views to access Elements by their defined Actions.

Syntax

1
<view Variable> := <expression Expression> <viewName Identifier>

Returns
The View.

Parameters

  • expression - The expression, which uses the View as an argument
  • May be one of open, await, find or assert

  • viewName - The name assigned to the View

Open Expression

The open expression opens a View specified by its name and returns it. It requires a corresponding View definition with that name.

Example

1
2
3
4
func myuiSteps()
myviewVar := open myview
myview.ClickLogingButton()
end

Await Expression

The await expression awaits a View and returns it.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
result := await ResultView, ErrorView
if result.is(ResultView) then
    println(Successful)
else
    println(Error)
end

View ResultView

end

View ErrorView

end

This expression also allows awaiting for one View from a set of Views:

Example

1
2
viewResult := await myView1, myView2, myView3
viewResult.is(myView1)

The example above waits for a View that is part of the set myView1 to myView3. The first View encountered is returned and stored in the viewResult variable. The is method checks which View has been returned. It returns true if the View is of type myView1.

Find Expression

The find expression finds and returns the View if available, otherwise null.

Example

1
2
3
func findRecord(viewName)
  return find viewName
end

Assert Expression

The assert expression returns the View if it exists, otherwise an assertion error will occur.

Example

1
2
3
func assertExample(viewName)
    return assert viewName
end

Note: More information about the assert expression is available in the Statement Language section.