ATX Learning (II) -Atx Weditor

1, Atx installation

Installation adb
install the latest version using the following command atx
pip install --pre -U uiautomator2 
phone after connected to a computer, you need to run the following command:
Programs python -m uiautomator2 init will need to deploy to the phone (once)

2、Atx Weditor

ATX Weditor library is a python, command-line installation 
pip install --pre weditor, command line start python -m weditor (PS: windows can double-click the shortcut weditor), it will automatically open a web page, use the page as Inspector

3. Connect the equipment

appium need to construct a desiredCapabilities, which typically corresponds to the sequence number field udid device.
With a common configuration file, for example

desired_caps = { 
# internet Android 
' PlatformName ' : ' the Android ' , 
# phone device name 
' deviceName ' : ' 2d869e6 ' , 
version # android system 
' platformVersion ' : ' . 9 ' , 
# installation package path 
# ' App ' : ' F: \ download \ XXX.apk ' , 
# APK package name 
' appPackage ' : ' com.tencent.mm ' ,
# apk的launcherActivity
' AppActivity ' : ' .ui.LauncherUI ' , 
# default neReset is false, do not reset the application state before the session, related to first start every time you start the same, not the same becomes true 
# do not reset the application before the session state defaults to false 
' NoReset ' : True, 
# ' appWaitActivity ' : ' com.tencent.mm.plugin.webview.ui.tools.WebViewUI ' , 
# following two lines of code that is for shielding the soft keyboard can input Chinese characters 
' unicodeKeyboard ' : True, # send unicode string encoding using 
# ' resetKeyboard ' : False, hides the keyboard # 
# on Android, this will automatically remove the application under test at the end of the session 
"full reset" : False,
 'chromeOptions ' : { ' androidProcess ' : ' com.tencent.mm.plugin.webview.ui.tools.WebViewUI ' } 
# " automationName " : " uiautomator2 " 
# newCommandTimeout set to a larger value 
# " newCommandTimeout " : 240 
}

 

atx is no such profile, required fields is only one serial number, ip address may be used here. Everything else is optional. Whether to start the application provides the user the right to choose.
atx code:

import uiautomator2 as u2
d = u2.connect("dgsdg")
d.set_fastinput_ime(True)
s = d.session("com.netease.cloudmusic")

 

Feel much more convenient, fastinput_ime is designed for automated custom input method support Chinese input, and some special instructions such as search, emptied.
d.session function corresponds to appium the session mechanism, each time related to the operation of the code will first test to see whether the application is alive.

Note: When atx connection can fill the phone's serial number or ip address. Because the test code is ultimately atx-agent communication services on a mobile phone and, so it supports fill in IP, but the computer needs to run code with the phone on the same network segment.

4, selection and operation control

Method appium common element is positioned find_element_by_xpath, find_element_by_id, find_element_by_text
a common wording is

driver.implicitly_wait ( 10 ) is provided to find the time element # 10s 
Element = driver.find_element_by_text ( " Settings " )
 IF Element: 
element.click () 
is converted into atx code 

D (text = " Settings " ) .click (timeout = 10 ) 
ATX is not recommended for use xpath, because you want to dump all of the hierarchy, slower. Recommended when used in combination with a variety of query conditions. 
A typical use of 

D (className = " android.widget.Button " , textContains = " Login " ) .click () 
# the using XPath 
d.xpath ( '//android.widget.Button[contains(@text, "login")] ' ) .click ()

 

5, frame processing bomb

Now the high version of the phone will have some basic rights confirmation window or install confirmation box. If not handled properly it will affect the very automation.

See a post that is configurable at the box shells can be resolved (PS: it should be only for the iOS)  https://testerhome.com/topics/14513

driver.switch_to.alert.accept () 
ATX approach a little more freedom, you are free to choose what treatment the pop, as well as how to deal with. A common method to automatically click the Install button 

d.watcher ( " the INSTALL " ) .when (= text " Installation " ) .click () 
d.watcher ( " the NEXT " ) .when (= text " Next " ) .click () 
d.watchers.watched = True

 

The official document: https://github.com/openatx/uiautomator2
References: https://testerhome.com/topics/14880

Guess you like

Origin www.cnblogs.com/dangkai/p/10938464.html