UIAutomator2 API documentation (c)

Selector object identifier 1.UI

用法d(text='Clock', className='android.widget.TextView')

Supports the following parameters, detailed information can refer UiSelector Java doc

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

# Click: Settings → personality topics:

method one:

d(description='设置', className='android.widget.ImageView').click()

d (text = 'personality theme', className = 'android.widget.TextView'). click ()

Method Two:

d(resourceId="com.miui.home:id/icon_title", text="设置").click()

d.xpath ( '// * [@ text = "character theme"]'). click ()

2. Get the UI object status and information

d(text="3D_H5").exists

d.exists(text="3D_H5")

d(text="3D_H5").info

# Get / set / clear the edit box contents

d (description = "Please enter the QQ number or mobile or mail") .get_text ()

d (description = "Please enter the QQ number or mobile or mail") .set_text ( "1234")

d (description = "Please enter the QQ number or mobile or mail") .clear_text ()

# Gets the center position coordinates

x, y = d (text = "Settings") .center ()

#x,y = d(text="设置").center(offset=(0, 0)) # left-top x, y

# Execute the click event in the UI objects

d (text = "Set") .click (timeout = 30) # delay to wait up to 30 seconds, did not find throws .UiObjectNotFoundError

d (text = "Settings") .click (offset = (0.5, 0.5)) # default click center coordinates

d (text = "Set") .click (offset = (0, 0)) # Click coordinate of the left - on

d (text = "Settings") .click (offset = (1, 1)) # Right click coordinates - lower

Guess you like

Origin www.cnblogs.com/sc912/p/11284660.html