Appium elements positioned in app

app targeting method, we talk Android phone targeting.

With the proviso that connect adb to a simulator or a mobile phone (connection not specifically explained here), demonstrated that it has connected to the device

adb devices

app elements of a positioning tool: UI Automator Viewer

This tool is Android SDK comes with a positioning tool, specific page screenshot as follows:

 

app element positioning tool two: Appium tool

Start Appium, after starting, there is a magnifying glass button page, as shown:

 

 Click the magnifying glass button to enter configuration items, if shown:

platformName - System Name

Version of the system - platformVersion

deviceName - model (free to add)

appPackage - app package name (here for example to Taobao)

appActivity - Welcome Page

noReset - Do not clear app in the original data (True) startup app

 

Get appPackage appActivity and methods, COM command to enter the Android-sdk / build-tools-29.0.2 directory, Run

aapt dump badging xxx.apk (installation package)

app package name

 

appActivity Name:

 

 

 

 

 After setting the parameters startup items, start a session.

 

 

Then said positioning element positioning expressions expression, appium of inherited eight targeting expression of selenium (selenium positioned in front of the eight have said, will not repeat them), but also have their own position expression, respectively :

 

AndroidUiAutomator positioning

Use UiSelector class UiAutomator element positioned in the handle to the parameters of the method is based positioning elements expression UiSelector

new UiSeletor (). function name ( "Positioning expression")

Examples of a UiSelector object, and then calls the interface by way of example.

The commonly used elements are positioned ANDROID_UIANTOMATOR and ACCESSIBILITY_ID

 

For chestnut:

Positioned by resrouce-id

find_element_by_android_uiautomator('new UiSelector().resourceId("com.taobao.taobao:id/textview_goods_title")')

 Located by text

find_element_by_android_uiautomator ( ' new new UiSelector (). text ( "text") ' )

 By targeting content-desc

find_element_by_android_uiautomator ( ' new new UiSelector (). Description ( "Baby tick') ' )

 

id, class, content-desc positioned

By locating id (resrouce-id)

find_element_by_id("com.taobao.taobao:id/textview_goods_title")

By positioning ClassName (class)

.find_element_by_class_name("android.widget.CheckBox")

By positioning AccessibilityId (content-desc)

find_element_by_accessibility_id ( " check baby " )

app localization is not recommended for use xpath location, not more and more to go into details here.

Guess you like

Origin www.cnblogs.com/xingyunqiu/p/11759494.html