Property Description Language Interface

The Property Description Language (PDL) is the way Kea interacts with the application under test, allowing users to interact with the mobile application under test through interface calls.

User Interface Interaction Events

Note

Currently, the underlying Property Description Language of Kea uses uiautomator2 as the interaction tool to interact with mobile devices.

For example, to send a click event to the application, you can use the following code:

d(resourceId="player_playback_button").click()

d is the driver of uiautomator2.

resourceId sets the identifier of the component for the selector to locate the component.

click() sends a click event to the component.

Here are some commonly used interaction events:

  • click

    d(text="OK").click()
    
  • long_click

    d(text="OK").long_click()
    
  • edit text

    d(text="OK").set_text("text")
    
  • rotate device

    d.rotate("l") # or left
    d.rotate("r") # or right
    
  • press [key]

    d.press("home")
    d.press("back")
    

When locating components, the following selectors can be used.

Selector

Selectors are used to identify specific components in the user interface, and they support the following parameters:

  • text, textContains, textMatches, textStartsWith

  • className, classNameMatches

  • description, descriptionContains, descriptionMatches, descriptionStartsWith

  • checkable, checked, clickable, longClickable

  • scrollable, enabled, focusable, focused, selected

  • packageName, packageNameMatches

  • resourceId, resourceIdMatches

  • index, instance

Examples

# 选择text值为 "More Options" 的控件并点击它。
d(text='More Options').click()

# 在一个选择器中使用多个参数。
# 选择具有text值为 "Clock" 和类名为 "android.widget.TextView" 的控件并点击它。
d(text='Clock', className='android.widget.TextView').long_click()

# 选择具有资源编号为 "com.example/input_box" 的控件,并将其文本值设置为 "Hello world"。
d(resourceId="com.example/input_box").set_text("Hello world")