Element Interactions

To interact with a GuiElement, from automation angle it must be in an interactable state. In the usual automation code, a test author writes a lot of waiting related code (and let’s not even touch the time.sleep.).

Automatic Contextual Dynamic Waiting

Arjuna does a granular automatic waiting of three types:
  • Waiting for the presence of an element when it is attempting to identify a GuiElement

  • Waiting for the right state (for example, clickability of an GuiElement when you enter text or want to click it)

  • Waiting for interaction to succeed (Arjuna, for example, retries click if interaction exception is raised).

Entering/Setting Text

You can enter text in a text box using enter_text call. It clicks on the element before entering text.

element.enter_text("user")

You can set text for an element using the text property. It clicks the element, clears text and then enters the text provided.

element.text = "user"

text is a property of GuiElement. element.text = “some_string” is equivalent of setting text of the text box.

To clear text without entering new text, you can use the clear_text call:

element.clear_text()

(Single/Double) Clicking an Element

element.click()
element.double_click()

Hovering Actions on an Element

element.hover()
element.hover_and_click()

Dragging/Dropping an Element

You can drag an element using drag method by providing an Offset specifying X and Y coordinate offsets as follows:

element.drag(offset=Screen.offset(10,20))

You can drop an element on another element using drop method by providing the target element and offsets specifying X and Y coordinate offsets as follows:

element.drop(target_element)
element.drop(target_element, source_offset=Screen.offset(10,20), target_offset=Screen.offset(30,50))

Here source_offset is from the source element and target_offset is from target element where the element is dropped. None or one or both of these can be provided in the call.

Checking/Unchecking/Toggling a Checkbox

The calls do not change the state if the checkbox is already in target state.

element.check()
element.uncheck()

If you want to switch the current state of checbox, use toggle:

element.toggle()

Selecting/Deselecting/Toggling an Element

The calls do not change the state if the element is already in target state.

element.select()
element.deselect()

If you want to switch the current state of an element, use toggle:

element.toggle()