本文主要是介绍1_weditor定位元素位置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
WEditor
安装
github项目地址
https://github.com/openatx/weditor
安装代码
pip install --pre --upgrade weditor
显示如下,则安装成功
C:\Users\Administrator.PC-20170907TLUD>pip install --pre --upgrade weditor
Collecting weditorDownloading https://files.pythonhosted.org/packages/90/8b/f886be1af89c3444d688a1edf843b99532be72d6800ef6f2bbcc9c65ff77/weditor-0.0.4.dev9.tar.gz (1.2MB)100% |████████████████████████████████| 1.2MB 976kB/s
Collecting tornado>=4.3 (from weditor)Downloading https://files.pythonhosted.org/packages/e1/17/83cecc0ff2f200d9b7160e67726b2f419c53453bbe22929582fb08fe9122/tornado-5.1b1.tar.gz (516kB)100% |████████████████████████████████| 522kB 2.0MB/sRequested tornado>=4.3 from https://files.pythonhosted.org/packages/e1/17/83cecc0ff2f200d9b7160e67726b2f419c53453bbe22929582fb08fe9122/tornado-5.1b1.tar.gz#sha256=b640a110c98dfea03554120463bd4cd675f3245f15111c8893773620c03db15f (from weditor), but installing version 4.5.2
Collecting futures>=3.0.5 (from weditor)Downloading https://files.pythonhosted.org/packages/cc/26/b61e3a4eb50653e8a7339d84eeaa46d1e93b92951978873c220ae64d0733/futures-3.1.1.tar.gz
Requirement already up-to-date: six in c:\users\administrator.pc-20170907tlud\appdata\local\programs\python\python35\lib\site-packages (from weditor)
Collecting pillow (from weditor)Downloading https://files.pythonhosted.org/packages/ab/d2/d27a21bd3e64db1ca1dc7dc16026a16d77f5c3ffca9ec619eddeea7c47ce/Pillow-5.1.0-cp35-cp35m-win_amd64.whl (1.6MB)100% |████████████████████████████████| 1.6MB 747kB/s
Building wheels for collected packages: weditor, tornado, futuresRunning setup.py bdist_wheel for weditor ... doneStored in directory: C:\Users\Administrator.PC-20170907TLUD\AppData\Local\pip\Cache\wheels\43\29\78\ab5d01cff3bb4b396ec21f9c7b18b8c4448349bffa94d50137Running setup.py bdist_wheel for tornado ... doneStored in directory: C:\Users\Administrator.PC-20170907TLUD\AppData\Local\pip\Cache\wheels\66\c9\52\2cfc6fe979b8a3378aecfccea025b5f2303ad1ddd12846d57cRunning setup.py bdist_wheel for futures ... doneStored in directory: C:\Users\Administrator.PC-20170907TLUD\AppData\Local\pip\Cache\wheels\f3\f9\c7\4fbf1faa6038faf183f6e3ea61f17a5f7eea5ab9a1dd7753fd
Successfully built weditor tornado futures
Installing collected packages: tornado, futures, pillow, weditorFound existing installation: tornado 4.5.2Uninstalling tornado-4.5.2:Successfully uninstalled tornado-4.5.2Found existing installation: Pillow 4.3.0Uninstalling Pillow-4.3.0:Successfully uninstalled Pillow-4.3.0
Successfully installed futures-3.1.1 pillow-5.1.0 tornado-5.1b1 weditor-0.0.4.dev9
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
运行如下代码
python -m weditor
则跳出浏览器,查看手机view
可以点击reload按钮更新查看的页面
WIFI网络链接可以直接输入设备IP(192.168.31.234),点击Connect按钮。
import uiautomator2 as u2
from time import sleepd = u2.connect('192.168.31.234')# 启动App
d.app_start("com.meizu.mzbbs")# 搜索
d(resourceId="com.meizu.mzbbs:id/j0").click()# 输入关键字
d(resourceId="com.meizu.mzbbs:id/p9").set_text("flyme")# 搜索按钮
d(resourceId="com.meizu.mzbbs:id/tp").click()sleep(2)# 停止app
d.app_stop("com.meizu.mzbbs")
app_start()和app_stop()用于启动和停止应用。
常用的定位方式:
ResourceId定位:
d(resourceId="com.meizu.mzbbs:id/tp").click()
Text定位:
d(text="精选").click()
Description定位:
d(description="..").click()
ClassName定位:
d(className="android.widget.TextView").click()
这篇关于1_weditor定位元素位置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!