Skip to content
QiTASC.com / UI Steps Language / Views /
View Actions
/ .. / .. /
View Actions





View Actions

After defining a View's Elements, the Actions to perform on them can be created. For example, clicking a button, or selecting an entry from a drop-down menu. If an Action will be performed on multiple Elements, for example, click on three different Elements, a unique Action must be written to invoke each Element. Information about how to call Actions in a Stepdef is available in the Stepdefs in UI Steps section.

Action Chains

Action chains perform a sequence of Actions separated by an arrow ->. The final Action in an Action chain must be one of: click, double click, drop, or type. Elements used in Action chains may require a dynamic modifier Actions eligible to be used in Action chains are indicated in the table below.

Example

1
2
action (input) hoverMe := hover(tutorials) -> hover(webDesign) ->
hover(input) -> type

UI Steps Actions Can Be Used in action Chain
Read Actions: Attribute, Content & Selected No
Modifying Actions
Capture No
Check No
Uncheck No
Clear No
Click Yes
Double Click Yes
Drag and Drop Yes
Drag and Drop with Coordinates Yes
Hover Yes
Pause Yes
Right Click Yes
Select No
Submit No
Swipe No
Type Yes

Read Actions

The attribute, content and selected Actions read and return data from their addressed Elements, but do not modify any content.

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

  • action - The Action. May be one of attribute, content or selected

    • attribute - Returns an arbitrary attribute of an Element
    • content - Retrieves an Element's content
    • selected - Returns whether or not a checkbox or a radio button is selected

Example

1
2
3
action (videoTv) getAttributeOfTv := attribute
action (menu) getContentOfMenu := content
action (yes) yesCheckbox := selected

Modifying Actions

Modifying Actions interact with the addressed Element in a way that changes their state or value.

Capture

Captures an image of the Element and returns it as a file.

Syntax

1
action (<elemAddressed Element>) <actionName Name> := capture

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (companyLogo) captureCompanyLogo := capture

Check

Checks a checkbox/radio button Element.

Syntax

1
action (<elemAddressed element>) <actionName Name> := check

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (yes) yesCheckbox := check

Uncheck

Unchecks a checkbox Element.

Syntax

1
action (<elemAddressed element>) <actionName Name> := uncheck

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (yes) yesCheckbox := uncheck

Clear

Clears the input of an Element. For example, clearing a search field.

Syntax

1
action (<elemAddressed element>) <actionName Name> := clear

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (searchField) clearSearchText := clear

Click

Clicks a button.

Syntax

1
action (<elemAddressed Element>) <actionName Name> := click

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (searchButton) doSearch := click

Double Click

Double-clicks on an Element.

Syntax

1
action (<elemAddressed element>) <actionName Name> := double click

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
2
3
4
5
6
view ExampleView
    elem x := "id('x')"
    elem y := "id('y')"

    action (x) doubleClickX := double click
    action (y) doubleClickY := hover(y) -> pause -> double click

Drag and Drop

An Action chain first defines a drag Action on an Element and a drop Action to drop it onto another Element.

Syntax

1
action (<elemDropped element>) <actionName Name> := drag(<elemDragged) -> pause -> drop

Parameters

  • elemDropped - The Element that will have another Element dropped on it

  • actionName - The name assigned to the Action chain

  • elemDragged - The name assigned to the Element to be dragged and dropped

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
stepdef "open interactjs homepage"
    vView := open interactJS
    delay(2)
    Page.maximizeWindow()
    delay(2)
    vView.dragAndDrop()
    delay(2)
end

view interactJS
url "https://interactjs.io/"

    elem DemoOnlyBtn := '//*[@id="basic-drag"]/label[4]' [dynamic]
    elem DragElem := '//*[@id="drag-1"]' [dynamic]
    elem ScaleElem := '//*[@id="scale-Element"]' [dynamic]

    action (DragElem) dragAndDrop := drag(ScaleElem) -> pause -> drop

end

In the example above, the Element ScaleElem is dragged. A pause Action is executed and ScaleElem is dropped onto DragElem.

Drag and Drop with Coordinates

intaQt is able to evaluate optional numeric parameters of an Action chain to control the drag and drop Action. The coordinates are given relative to the drop target's center.

Syntax

1
<dragAndDropaction Name>(<offsetX Number>, <offsetY Number>)

Parameters

  • dragAndDropaction - The drag and drop identifier

  • offsetX - The distance in pixels from the drop target's center along the X-axis

    • Positive numbers indicate a rightward direction, while negative numbers indicate a leftward direction
  • offsetY - The distance in pixels from the drop target's center along the Y-axis

    • Positive numbers indicate a downward direction, while negative numbers indicate an upward direction

Note: The drop location can be outside of the drop target but should stay within the browser's window. If not, intaQt will throw an out of bounds of viewport error message.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
stepdef "open interactjs homepage"
    vView := open interactJS
    //wait with timeout
    delay(2)
    Page.maximizeWindow()
    delay(2)
    vView.dragAndDrop(30,-30)
    delay(2)
end

view interactJS
    url "http://interactjs.io/"
    elem DragElem := '//*[@id="drag-1"]' [visible]
    elem DropBox := '//*[@id="demos"]/div[1]/div[4]' [visible]

    action (DropBox) dragAndDrop := drag(DragElem) -> pause -> drop

end

Hover

Hovers over an Element, for example, to open a drop-down menu. hover must be used in an Action chain that first defines the Element to be hovered over and must end with one of: click, double click, drag or type Action.

Syntax

1
action (<elemTarget Name>) <actionName Name> := hover(<elem Name>)-> ... click
Parameters

  • elemTarget - The target ction for the final Action in the Action chain

    • For example, if the final Action is click after navigating through a drop-down menu
  • actionName - The name assigned to the Action chain

  • elem - The Element hovered over

Example

1
2
3
4
5
6
7
view MainNavigationView
   elem menu1 := ".//*[contains(text(), 'Menu')]"
   elem menu2 := ".//*[text() = 'SubMenu1']" [dynamic]
   elem menu3 := ".//*[text() = 'SubMenu2]" [dynamic]

   action (menu3) navigateToSubmenu2 := hover(menu1)-> hover(menu2)-> click
end

Pause

Pauses for 500 milliseconds and must be used in an Action chain. For example, if using the drag and drop Actions, a pause can be entered between them.

Syntax

1
2
action (<elemAddressed Name>) <actionName Name>
:= <action1 action> -> pause -> ... <action2 action>
Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

  • action1 The Action that precedes the pause

  • action2 - The Action that follows the pause

Example

1
2
3
4
5
6
view ExampleView
    elem x := "id('x')"
    elem y := "id('y')"

    action (x) dragAndDrop := drag(y) -> pause -> drop
end

Right Click

Performs a right click on the specified element.

Syntax

1
action (<elemAddressed element>) <actionName Name> := right click

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
2
3
4
view MyView
    elem el := "<xpath>"
    action (el) doRightClick := right click
end

Select

Selects an entry from a drop-down menu.

Syntax

1
action (<elemAddressed element>) <actionName Name> := select

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (categories) selectCategory := select

Submit

Submits a form. Unlike click, which must be used on the submit button, submit can be performed on any form Element.

Syntax

1
action (<elemAddressed element>) <actionName Name> := submit

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (registrationForm) submitRegForm := submit

Swipe

Performs a swipe touch event, starting from a defined Element. The model that calls it must specify either:

  • An offset in pixels from the Element.

  • A swipe direction with a distance relative to the screen size.

Syntax

1
action (<elemAddressed element>) <actionName Name> := swipe
Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (scrollerBar) slide := swipe

Swipe With Pixel Offset

The swipe's pixel offsets specify the swipe distance in pixels, relative to the starting Element. It takes speed as an optional parameter.

Function Syntax

1
2
3
4
    //Without speed parameter
    <view Name>.<swipe Name>(<offsetX Number>, <offsetY Number>)
    // With speed parameter
    <view Name>.<swipe Name>(<offsetX Number>, <offsetY Number>, <speed String>)
Parameters

  • view - The View's name, as defined in the Stepdef

  • swipe - The swipe's name, as defined in the View

  • offsetX - The distance in pixels from the Element along the X-axis

    • Positive numbers indicate a rightward direction, while negative numbers indicate a leftward direction
  • offsetY - The distance in pixels from the Element along the Y-axis

    • Positive numbers indicate a downward direction, while negative numbers indicate an upward direction
  • speed - The speed assigned to the swipe

    • Can be one of: "normal" (default) or "fast"

Example

1
2
3
4
5
6
    // swipe 500 pixels left at normal speed.
    formView.doSwipe(-500, 0)
    // swipe 500 pixels down at normal speed.
    formView.doSwipe(0, 500, "normal")
    // swipe 500 pixels right and down at fast speed.
    formView.doSwipe(500, 500, "fast")

Swipe With Direction

The swipe with direction does not provide exact pixel distances and is suitable for cases when the accuracy of the swipe is not as important (for example, to dismiss a list item by swiping to the left or right). It takes speed and distance as optional parameters.

Syntax

1
2
3
    <view Name>.<swipe Name>(<direction String>)
    <view Name>.<swipe Name>(<direction String>, <distance String>)
    <view Name>.<swipe Name>(<direction String>, <distance Sting>, <Speed String>)

Parameters

  • direction - The swipe's direction

    • Can be one of: "up" "down" "left" or "right"
  • distance - The swipe's distance dependent on the screen's size

    • Width is used when swiping to the left/right and height for up/down
      • Can be one of:
        • "short" swipes less than ⅓ of the width or height
        • "medium" (default) swipes between ⅓ and ⅔ of the width or height
        • "long" swipes greater than ⅔ of the width or height
  • speed - The swipe's speed

    • Can be one of: "normal" (default) or "fast"

Example

1
2
3
4
5
6
    // medium swipe left at normal speed.
    formView.doSwipe("left")
    // short swipe up at normal speed.
    formView.doSwipe("up", "short")
    // long swipe up at fast speed.
    formView.doSwipe("down", "long", "fast")

Type

Types text into a field.

Syntax

1
action (<elemAddressed element>) <actionName Name> := type

Parameters

  • elemAddressed - The Element that an Action will address

  • actionName - The name assigned to the Action

Example

1
action (searchField) defineSearchText := type