最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Mac中安装和初始化weditor

Mac crifan 575浏览 0评论
折腾:
【未解决】Mac中初始化安卓手机红米Note10X的uiautomator2开发环境
期间,继续参考自己教程:
weditor · 安卓自动化测试利器:uiautomator2
和官网:
openatx/uiautomator2: Android Uiautomator2 Python Wrapper
去安装和初始化weditor:
pip install -U weditor
详细log
 pip install -U weditor     
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting weditor
  Downloading http://mirrors.aliyun.com/pypi/packages/24/66/4a700a932e1be1c64821b8b2b25ddfbdf63d0c5f0968f904b28f1878cd0d/weditor-0.6.3-py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 33 kB/s 
Collecting facebook-wda>=1.0.5
  Downloading http://mirrors.aliyun.com/pypi/packages/5e/58/3a658ba5bb5dd88b71c7e2e32b9831784ee84b3de265096089db682c460b/facebook_wda-1.3.4-py3-none-any.whl (25 kB)
Requirement already satisfied, skipping upgrade: tornado>=4.3 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from weditor) (6.0.3)
Collecting logzero
  Downloading http://mirrors.aliyun.com/pypi/packages/b3/68/aa714515d65090fcbcc9a1f3debd5a644b14aad11e59238f42f00bd4b298/logzero-1.7.0-py2.py3-none-any.whl (16 kB)
Collecting cached-property
  Downloading http://mirrors.aliyun.com/pypi/packages/48/19/f2090f7dad41e225c7f2326e4cfe6fff49e57dedb5b53636c9551f86b069/cached_property-1.5.2-py2.py3-none-any.whl (7.6 kB)
Collecting pillow
  Downloading http://mirrors.aliyun.com/pypi/packages/59/61/5b3973f58efc5dee70d28181da62d1f957e3fb16419a1c5b142d766ba340/Pillow-8.2.0-cp37-cp37m-macosx_10_10_x86_64.whl (2.8 MB)
     |████████████████████████████████| 2.8 MB 361 kB/s 
Collecting uiautomator2>=2.10.1
  Downloading http://mirrors.aliyun.com/pypi/packages/20/b1/db5d40f38d349188011a988c83e688ed111133d33cfb0db5d26b2ef5b30b/uiautomator2-2.14.1.tar.gz (676 kB)
     |████████████████████████████████| 676 kB 448 kB/s 
Requirement already satisfied, skipping upgrade: six in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from weditor) (1.14.0)
Collecting attrdict~=2.0.1
  Downloading http://mirrors.aliyun.com/pypi/packages/ef/97/28fe7e68bc7adfce67d4339756e85e9fcf3c6fd7f0c0781695352b70472c/attrdict-2.0.1-py2.py3-none-any.whl (9.9 kB)
Requirement already satisfied, skipping upgrade: requests>=2.9.1 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from facebook-wda>=1.0.5->weditor) (2.23.0)
Collecting Deprecated~=1.2.6
  Downloading http://mirrors.aliyun.com/pypi/packages/fb/73/994edfcba74443146c84b91921fcc269374354118d4f452fb0c54c1cbb12/Deprecated-1.2.12-py2.py3-none-any.whl (9.5 kB)
Collecting retry
  Downloading http://mirrors.aliyun.com/pypi/packages/4b/0d/53aea75710af4528a25ed6837d71d117602b01946b307a3912cb3cfcbcba/retry-0.9.2-py2.py3-none-any.whl (8.0 kB)
Collecting whichcraft
  Downloading http://mirrors.aliyun.com/pypi/packages/b5/a2/81887a0dae2e4d2adc70d9a3557fdda969f863ced51cd3c47b587d25bce5/whichcraft-0.6.1-py2.py3-none-any.whl (5.2 kB)
Collecting progress~=1.3
  Downloading http://mirrors.aliyun.com/pypi/packages/38/ef/2e887b3d2b248916fc2121889ce68af8a16aaddbe82f9ae6533c24ff0d2b/progress-1.5.tar.gz (5.8 kB)
Collecting adbutils<1.0,>=0.8.2
  Downloading http://mirrors.aliyun.com/pypi/packages/aa/72/534eb73e6f7d3efac66cb5cc64433c8b8e51d5a957fe40bdc231cf3a90bc/adbutils-0.10.0-py3-none-macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (997 kB)
     |████████████████████████████████| 997 kB 75 kB/s 
Collecting lxml>=4.3
  Downloading http://mirrors.aliyun.com/pypi/packages/1e/3e/f0abc15d5dac50939bccc589aae336d5ead4c72e7ad1039a2e0f3630ea92/lxml-4.6.3-cp37-cp37m-macosx_10_9_x86_64.whl (4.5 MB)
     |████████████████████████████████| 4.5 MB 2.5 MB/s 
Collecting packaging~=20.3
  Downloading http://mirrors.aliyun.com/pypi/packages/3e/89/7ea760b4daa42653ece2380531c90f64788d979110a2ab51049d92f408af/packaging-20.9-py2.py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 2.5 MB/s 
Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from requests>=2.9.1->facebook-wda>=1.0.5->weditor) (3.0.4)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from requests>=2.9.1->facebook-wda>=1.0.5->weditor) (1.25.8)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from requests>=2.9.1->facebook-wda>=1.0.5->weditor) (2.9)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from requests>=2.9.1->facebook-wda>=1.0.5->weditor) (2019.11.28)
Collecting wrapt<2,>=1.10
  Downloading http://mirrors.aliyun.com/pypi/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz (27 kB)
Requirement already satisfied, skipping upgrade: decorator>=3.4.2 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from retry->facebook-wda>=1.0.5->weditor) (4.4.1)
Collecting py<2.0.0,>=1.4.26
  Downloading http://mirrors.aliyun.com/pypi/packages/67/32/6fe01cfc3d1a27c92fdbcdfc3f67856da8cbadf0dd9f2e18055202b2dc62/py-1.10.0-py2.py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 6.1 MB/s 
Collecting deprecation<3.0,>=2.0.6
  Downloading http://mirrors.aliyun.com/pypi/packages/02/c3/253a89ee03fc9b9682f1541728eb66db7db22148cd94f89ab22528cd1e1b/deprecation-2.1.0-py2.py3-none-any.whl (11 kB)
Collecting apkutils2<2.0,>=1.0.0
  Downloading http://mirrors.aliyun.com/pypi/packages/e5/d0/432fb6fb1fe48aa0ea1c80e8dec4a26f70c868999c076f92af88582ae91a/apkutils2-1.0.0.tar.gz (60 kB)
     |████████████████████████████████| 60 kB 10.6 MB/s 
Requirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages (from packaging~=20.3->uiautomator2>=2.10.1->weditor) (2.4.6)
Collecting pyelftools
  Downloading http://mirrors.aliyun.com/pypi/packages/6f/50/3d7729d64bb23393aa4c166af250a6e6f9def40c90bf0e9af3c5ad25b6f7/pyelftools-0.27-py2.py3-none-any.whl (151 kB)
     |████████████████████████████████| 151 kB 11.8 MB/s 
Collecting cigam
  Downloading http://mirrors.aliyun.com/pypi/packages/3c/d0/19ff49c1938aea4e0076ee084ca23845408cffb51582b2be975f926533b5/cigam-0.0.3-py3-none-any.whl (3.8 kB)
Collecting xmltodict
  Downloading http://mirrors.aliyun.com/pypi/packages/28/fd/30d5c1d3ac29ce229f6bdc40bbc20b28f716e8b363140c26eff19122d8a5/xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB)
Using legacy setup.py install for uiautomator2, since package 'wheel' is not installed.
Using legacy setup.py install for progress, since package 'wheel' is not installed.
Using legacy setup.py install for wrapt, since package 'wheel' is not installed.
Using legacy setup.py install for apkutils2, since package 'wheel' is not installed.
Installing collected packages: cached-property, attrdict, pillow, wrapt, Deprecated, py, retry, facebook-wda, logzero, whichcraft, progress, packaging, deprecation, pyelftools, cigam, xmltodict, apkutils2, adbutils, lxml, uiautomator2, weditor
    Running setup.py install for wrapt ... done
    Running setup.py install for progress ... done
    Running setup.py install for apkutils2 ... done
    Running setup.py install for uiautomator2 ... done
Successfully installed Deprecated-1.2.12 adbutils-0.10.0 apkutils2-1.0.0 attrdict-2.0.1 cached-property-1.5.2 cigam-0.0.3 deprecation-2.1.0 facebook-wda-1.3.4 logzero-1.7.0 lxml-4.6.3 packaging-20.9 pillow-8.2.0 progress-1.5 py-1.10.0 pyelftools-0.27 retry-0.9.2 uiautomator2-2.14.1 weditor-0.6.3 whichcraft-0.6.1 wrapt-1.12.1 xmltodict-0.12.0
然后去初始化
python -m weditor
首次还会提示:
您要应用程序 Python3.7 接受传入网络连接吗?
点击允许
输入 手机 id
~  adb devices
List of devices attached
orga4pmzee4ts47t    device
得到的:orga4pmzee4ts47t
点击 实时
即可看到画面:
为了节省资源,切换回 静态:
然后点击查看元素属性:
属性是:
Selected Element  Clear Canvas
Tap Widget(Beta) Tap Send Keys
Prop    Value
activity    .ui.LauncherUI
XPathLite    //*[@resource-id="com.tencent.mm:id/awv"]/android.widget.RelativeLayout[2]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]
坐标 % px    (0.814, 0.287) 点击
className    android.widget.LinearLayout
* index    0
* text    
* resourceId    
* package    com.tencent.mm
* description    
* checkable    false
* clickable    false
* enabled    true
* focusable    false
* focused    false
* scrollable    false
* longClickable    false
* password    false
* selected    false
# rect    {"x":707,"y":558,"width":203,"height":452} 代码
即可。说明可以正常调试了。
对应的log输出是:
 python -m weditor
listening on http://192.168.31.12:17310
[I 210402 22:52:49 web:2246] 200 GET / (::1) 18.51ms
[I 210402 22:52:49 web:2246] 200 GET /cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap.min.css (::1) 19.03ms
[I 210402 22:52:49 web:2246] 200 GET /cdn.jsdelivr.net/npm/jstree@3.3.8/dist/themes/default/style.min.css (::1) 33.71ms
[I 210402 22:52:49 web:2246] 200 GET /static/libs/fontawesome/css/font-awesome.min.css (::1) 37.99ms
[I 210402 22:52:49 web:2246] 200 GET /cdn.jsdelivr.net/bootstrap.select/1.12.2/css/bootstrap-select.min.css (::1) 42.20ms
[I 210402 22:52:49 web:2246] 200 GET /unpkg.com/element-ui/lib/theme-chalk/index.css (::1) 52.95ms
[I 210402 22:52:49 web:2246] 200 GET /static/libs/css/buttons.css (::1) 59.13ms
[I 210402 22:52:49 web:2246] 200 GET /static/style.css?v=36c1d231ca96af637a1b43fdeec15aec (::1) 64.98ms
[I 210402 22:52:49 web:2246] 200 GET /cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js (::1) 20.32ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/bootstrap/3.3.7/js/bootstrap.min.js (::1) 81.69ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/bootstrap.select/1.12.2/js/bootstrap-select.min.js (::1) 100.70ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/ace.min.js (::1) 110.94ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/mode-python.min.js (::1) 124.62ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/ext-language_tools.min.js (::1) 135.78ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/ext-searchbox.min.js (::1) 8.32ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/theme-monokai.js (::1) 16.38ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/npm/jstree@3.3.8/dist/jstree.min.js (::1) 23.69ms
[I 210402 22:52:50 web:2246] 200 GET /static/libs/vue-2.5.16/vue.js?v=cbe2b9b2fb6955decf033515d079e44b (::1) 31.83ms
[I 210402 22:52:50 web:2246] 200 GET /unpkg.com/element-ui/lib/index.js (::1) 50.16ms
[I 210402 22:52:50 web:2246] 200 GET /static/js/common.js?v=f1c2d6b24d012c4fc2e22595bd549793 (::1) 53.17ms
[I 210402 22:52:50 web:2246] 200 GET /static/js/index.js?v=1e93d9fb27bafdd173d79477b015322e (::1) 5.14ms
[I 210402 22:52:50 web:2246] 200 GET /static/loading.svg (::1) 7.07ms
[I 210402 22:52:50 web:2246] 200 GET /static/running.svg (::1) 13.29ms
[I 210402 22:52:50 web:2246] 200 GET /static/libs/fontawesome/fonts/fontawesome-webfont.woff2?v=4.7.0 (::1) 17.68ms
[I 210402 22:52:50 web:2246] 200 GET /cdn.jsdelivr.net/bootstrap/3.3.7/fonts/glyphicons-halflings-regular.woff2 (::1) 19.46ms
[I 210402 22:52:50 web:2246] 200 GET /api/v1/version (::1) 3.20ms
[I 210402 22:52:50 web:2246] 101 GET /ws/v1/python (::1) 14.49ms
[I 210402 22:52:50 shell:172] create process pid: 15728
[I 210402 22:52:50 web:2246] 200 GET /unpkg.com/element-ui/lib/theme-chalk/fonts/element-icons.woff (::1) 22.82ms
[W 210402 22:52:51 web:2246] 404 GET /apple-touch-icon-precomposed.png (::1) 2.62ms
[W 210402 22:52:51 web:2246] 404 GET /apple-touch-icon.png (::1) 2.38ms
[I 210402 22:52:51 web:2246] 200 GET /favicon.ico (::1) 5.28ms
[I 210402 22:55:37 web:2246] 200 POST /api/v1/connect (::1) 74.36ms
[I 210402 22:56:04 web:2246] 200 POST /api/v1/connect (::1) 26.35ms
[I 210402 22:56:05 web:2246] 200 GET /api/v2/devices/android%3Aorga4pmzee4ts47t/hierarchy (::1) 1126.95ms
[I 210402 22:56:06 web:2246] 200 GET /api/v2/devices/android%3Aorga4pmzee4ts47t/hierarchy (::1) 756.98ms
。。。
[I 210402 22:56:39 web:2246] 200 GET /api/v2/devices/android%3Aorga4pmzee4ts47t/hierarchy (::1) 743.71ms
[I 210402 22:56:39 page:204] Serial: android:orga4pmzee4ts47t
[I 210402 22:56:40 web:2246] 200 GET /api/v1/devices/android%3Aorga4pmzee4ts47t/screenshot (::1) 475.57ms
[I 210402 22:56:41 web:2246] 200 GET /api/v2/devices/android%3Aorga4pmzee4ts47t/hierarchy (::1) 946.91ms
即可。
另外,可以导出 元素结构:
点击右边的 Hierarchy,可以看到页面元素树状结构表:
点击顶部的 Dump Hierarchy,可以刷新到最新页面的结构:
【总结】
此处如之前所总结的:
pip install -U weditor 
去安装weditor
然后用:
python -m weditor
启动。
打开网页:
http://localhost:17310
  • 连接设备
    • 输入 (从adb devices中得到的)安卓设备id
    • 点击Connect,看到绿色🚦红绿灯标识,标识连接上了。
  • 看安卓设备画面
    • 点击 实时,即可看到安卓手机的实时画面。
    • 如果只是想要调试页面元素,则可以切换会 静态
  • 查看属性
    • 点击画面中元素,即可看到属性
  • 查看元素结构
    • 点击顶部的 Dump Hierarchy,点击右边切换到 Hierarchy,可以看到最新页面的结构

转载请注明:在路上 » 【已解决】Mac中安装和初始化weditor

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.181 seconds, using 23.35MB memory