Skip to content

Commit 89ea41f

Browse files
authored
Merge pull request #1100 from openatx/support_adb_transport_id
add usage and update adbutils version
2 parents 196a280 + 550095a commit 89ea41f

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

README_CN.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ screenOn': True, 'sdkInt': 27, 'naturalOrientation': True}
7373

7474
一般情况下都会成功,不过也可能会有意外。可以加QQ群反馈问题(群号在最上面),群里有很多大佬可以帮你解决问题。
7575

76-
## Sponsors
77-
Thank you to all our sponsors! ✨🍰✨
78-
79-
### 金牌赞助商(Gold Sponsor)
80-
Empty
81-
8276
# Article Recommended
8377
优秀文章推荐 (欢迎QQ群里at我反馈)
8478

@@ -155,7 +149,7 @@ Empty
155149
[uiauto.dev](https://github.com/codeskyblue/uiauto.dev) 是一个独立与uiautomator2之外的一个项目,用于查看图层结构的。属于旧版项目[weditor的重构版本](https://github.com/openatx/weditor),后续也许会收费(价格肯定物超所值),来支持当前这个项目继续维护下去。感兴趣的可以加群讨论(也包含提需求) QQ群 536481989
156150

157151
# Connect to a device
158-
use serialno to connect device eg. `123456f` (seen from `adb devices`)
152+
方法1: 使用设备序列号链接设备 例如序列号. `Q5S5T19611004599` (seen from `adb devices`)
159153

160154
```python
161155
import uiautomator2 as u2
@@ -164,14 +158,34 @@ d = u2.connect('123456f') # alias for u2.connect_usb('123456f')
164158
print(d.info)
165159
```
166160

167-
Serial can be passed through env-var `ANDROID_SERIAL`
161+
方法2: 序列号可以通过环境变量传递 `ANDROID_SERIAL`
168162

169163

170164
```python
171165
# export ANDROID_SERIAL=123456f
172166
d = u2.connect()
173167
```
174168

169+
方法3: 通过transport_id指定设备
170+
171+
```sh
172+
$ adb devices -l
173+
Q5S5T19611004599 device 0-1.2.2 product:ELE-AL00 model:ELE_AL00 device:HWELE transport_id:6
174+
```
175+
176+
这里可以看到transport_id:6
177+
178+
> 也可以通过 adbutils.adb.list(extended=True)获取所有连接的transport_id
179+
> 参考 https://github.com/openatx/adbutils
180+
181+
```python
182+
import adbutils # 需要版本>=2.9.1
183+
import uiautomator2 as u2
184+
dev = adbutils.device(transport_id=6)
185+
d = u2.connect(dev)
186+
```
187+
188+
175189
# Command line
176190
其中的`$device_ip`代表设备的ip地址
177191

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include = ["*/assets/*"]
1212
python = "^3.8"
1313
requests = "*"
1414
lxml = "*"
15-
adbutils = "^2.8.9"
15+
adbutils = "^2.9.1"
1616
Pillow = "*"
1717
retry2 = "^0.9.5"
1818

0 commit comments

Comments
 (0)