Skip to content

Commit

Permalink
3.0.50
Browse files Browse the repository at this point in the history
  • Loading branch information
rev1si0n committed Dec 3, 2022
1 parent d762785 commit 1cf452d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ MANIFEST
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ d.press_keycode(KeyCodes.KEYCODE_CALL)

```python
quality = 60 # 截图质量,默认为全画质
d.take_screenshot(quality).save("screenshot.png")
d.screenshot(quality).save("screenshot.png")
# 截取屏幕上特定区域的图像
# Bound 的参数 top,left 等定义:

Expand All @@ -1222,7 +1222,7 @@ d.take_screenshot(quality).save("screenshot.png")

# 正常情况下 top 永远小于 bottom,left 永远小于 right
bound = Bound(top=50, bottom=80, left=50, right=80)
d.take_screenshot(quality, bound=bound).save("partial.png")
d.screenshot(quality, bound=bound).save("partial.png")
```

> 点击屏幕上的一个点
Expand Down Expand Up @@ -1378,11 +1378,27 @@ element.wait_until_gone(10*1000)

# 获取该元素的截图(不是全屏,只是该元素)
# quality 为截图质量 1-100
element.take_screenshot(quality=60)
element.screenshot(quality=60)

# 将此 APP 拖动归类到 购物 文件夹(依据实际情况修改)
element.drag_to(Selector(text="购物"))

#########
# 查找同级或者子级元素
#########
# 有时候会有一些重复元素或者无明显特征的元素,很难去定位
# 这时你可以通过查找子级/同级元素的方法来缩小查找范围
# 子级元素,举例为:一个聊天登录框,里面的输入框即为登录框的子级元素
# 同级元素,举例为:聊天输入框里面的用户名和密码框为同级原始(正常情况下)
form = d(resourceId="login_form")
form.child(index=1)
# 这将获取到 login_form 下 index 为 0 的元素
form.child(index=1).sibling()
# 你也这样来找与 login_form 同级的找回密码按钮
#(其实已经可以通过字符串判断了,就不需要这样做了,这里只是演示)
form.sibling(textContains="找回密码")
# 它们本身就是一个element,你可以对其做任何 element 的操作


############################
# 现在 element 改变了其意义,变为选择了输入框
Expand Down
2 changes: 1 addition & 1 deletion lamda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Distributed under MIT license.
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
__version__ = "3.0"
__build__ = 48
__build__ = 50
18 changes: 18 additions & 0 deletions lamda/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io
import re
import sys
import copy
import time
import uuid
import json
Expand Down Expand Up @@ -295,6 +296,23 @@ def __str__(self):
for k, v in self._selector.items()])
return "Object: {}".format(selector)
__repr__ = __str__
def _child_sibling(self, name, **selector):
s = copy.deepcopy(self._selector)
s.setdefault("childOrSibling", [])
s.setdefault("childOrSiblingSelector", [])
s["childOrSiblingSelector"].append(selector)
s["childOrSibling"].append(name)
return self.__class__(self.stub, s)
def child(self, **selector):
"""
匹配选择器里面的子节点
"""
return self._child_sibling("child", **selector)
def sibling(self, **selector):
"""
匹配选择器的同级节点
"""
return self._child_sibling("sibling", **selector)
def take_screenshot(self, quality=100):
"""
对选择器选中元素进行截图
Expand Down
2 changes: 2 additions & 0 deletions lamda/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class SecurityException(Exception):
""" Exception """
class ServiceUnavailable(Exception):
""" Exception """
class StaleObjectException(Exception):
""" Exception """
class StartupActivityNotFound(Exception):
""" Exception """
class UiAutomatorException(Exception):
Expand Down
2 changes: 1 addition & 1 deletion tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ python3 -u startmitm.py 192.168.1.2 --mode upstream:example.com:8080 --upstream-
截获 DNS 请求需要确保 mitmproxy 的版本 >= 9.0.0(且 Python>=3.9),且需要以**管理员**或者**root**身份运行脚本。
部分系统上会存在自带的 DNS 服务,在使用该功能前请务必确保没有其他服务使用了 53 端口。

此选项与上方 `--nameserver` 意义不同,此选项专指 dns 中间人配置
此选项与上方 `--nameserver` 意义不同,`--dns` 选项专指 dns 中间人

> DNS 中间人,默认上游 DNS 服务器为 1.1.1.1
```bash
Expand Down
4 changes: 1 addition & 3 deletions tools/socks5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ RUN apk add bash make g++ git
RUN mkdir -p /tmp/workdir
WORKDIR /tmp/workdir

RUN wget https://www.inet.no/dante/files/dante-1.4.3.tar.gz
RUN tar -xzf dante-1.4.3.tar.gz

RUN wget https://www.inet.no/dante/files/dante-1.4.3.tar.gz -O - | tar -xz
WORKDIR /tmp/workdir/dante-1.4.3

ENV ac_cv_func_sched_setscheduler=no
Expand Down

0 comments on commit 1cf452d

Please sign in to comment.