因为本人也刚开始学着做一些UI自动化的工作。想找一款定位元素的工具。最后看着同事用着比较爽,被顺利的圈粉。

安装很简单,但前提是你已经安装了pip

1.执行pip install weditor命令

weditor安装和使用-编程知识网

2.启动weditor,执行python -m weditor

weditor安装和使用-编程知识网

3.连接手机

 a.首先adb devices获取到设备号

 weditor安装和使用-编程知识网

b.点击connect ,出现小麦穗,点击Dump Hierarchy

  weditor安装和使用-编程知识网

 

 

此时就可以开始学习了喽

 

 

遇到的问题:

1.忘记开了fiddler代理,导致执行pip install weditor失败。

  错误如下:


  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)'),)': /simple/weditor/        WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)'),)': /simple/weditor/        WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)'),)': /simple/weditor/        WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)'),)': /simple/weditor/        WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)'),)': /simple/weditor/        Could not fetch URL https://pypi.org/simple/weditor/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/weditor/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)'),)) – skipping                               


此时关闭fiddler就可以。但是如果确认是代理都关闭了,还是安装失败。我看网上说失败的还有pip源的速度很慢。推荐看这部片文章:https://blog.csdn.net/lsf_007/article/details/87931823

2.weditor安装成功后,启动时提示:atx-agent recover failed

    log提示: Retrying (Retry(total=2, connect=3, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionAbortedError(10053, '你的主机中的软件中止了一个已 建立的连接。', None, 10053, None))': /version    

这时候我们安装一下 :pip install –upgrade –pre uiautomator2   

安装完成之后就可以连接了。

看到了一篇处理weditor异常处理的帖子:https://www.urlteam.org/2019/02/android%E8%87%AA%E5%8A%A8%E5%8C%96%E4%B9%8B-atx%E5%BD%95%E6%94%BE%E7%BC%96%E8%BE%91%E5%99%A8weditor%E7%9A%84%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%E4%B8%8E%E5%BC%82%E5%B8%B8%E8%A7%A3%E5%86%B3/