AirtestProject / AirtestProject/AirtestIDE
关于一个新element的请求
- Lingua principale
- Nessun dato sulla lingua
- Stelle
- 236
- Fork
- 40
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
(请尽量按照下面提示内容填写,有助于我们快速定位和解决问题,感谢配合。**否则直接关闭。**)
**(重要!根据问题类型选择分类)**
* 图像识别相关问题 -> https://github.com/AirtestProject/Airtest/issues
* 控件识别、树状结构、poco库报错 -> https://github.com/AirtestProject/Poco/issues
* 测试开发环境AirtestIDE使用问题(本软件) -> 本页面
**详细描述问题bug:**
bug描述 我在崩坏 星琼铁道中想要让所有带垃圾桶标志的仪器全部强化,

**复现步骤:**
我的代码是:
# -*- encoding=utf8 -*-
__author__ = "Lenovo"
from airtest.core.api import *
auto_setup(__file__)
if exists(Template(r"tpl1745058564521.png", record_pos=(0.348, 0.005), resolution=(1280, 720))):
touch(Template(r"tpl1745058564521.png", record_pos=(0.348, 0.005), resolution=(1280, 720)))
wait(Template(r"tpl1745058729271.png", record_pos=(0.005, 0.245), resolution=(1280, 720)),timeout=1000)
touch(Template(r"tpl1745058739197.png", record_pos=(0.006, 0.236), resolution=(1280, 720)))
wait(Template(r"tpl1745058832499.png", record_pos=(0.343, -0.249), resolution=(1280, 720)),timeout=1000)
touch((1079,32))
if not exists(Template(r"tpl1745691612798.png", record_pos=(-0.419, -0.241), resolution=(1280, 720))):
wait(Template(r"tpl1745059871971.png", record_pos=(-0.455, -0.05), resolution=(1280, 720)),timeout=1000)
touch(Template(r"tpl1745059871971.png", record_pos=(-0.455, -0.05), resolution=(1280, 720)))
if exists(Template(r"tpl1745691746778.png", record_pos=(-0.152, 0.235), resolution=(1280, 720))):
wait(Template(r"tpl1745060004691.png", record_pos=(-0.232, 0.237), resolution=(1280, 720)),timeout=1000)
touch((447,656))
wait(Template(r"tpl1745724151328.png", record_pos=(-0.366, 0.236), resolution=(1280, 720)))
touch((166,657))
wait(Template(r"tpl1745724180769.png", record_pos=(0.391, -0.23), resolution=(1280, 720)))
touch((1139,60))
wait(Template(r"tpl1745724212782.png", record_pos=(0.355, -0.145), resolution=(1280, 720)))
touch ((1057,172))
touch ((591,28))
wait(Template(r"tpl1745724918793.png", record_pos=(0.464, -0.251), resolution=(1280, 720)))
a=838
b=151
i=5
while i < 5000:
if not exists(Template(r"tpl1745060315000.png", record_pos=(0.005, -0.005), resolution=(1280, 720))):
b=b+10
locate=(a,b)
touch(locate,duration=1)
else:
touch(Template(r"tpl1745060315000.png", record_pos=(0.005, -0.005), resolution=(1280, 720)))
wait(Template(r"tpl1745060387089.png", record_pos=(0.405, 0.232), resolution=(1280, 720)))
touch((1166,650))
wait(Template(r"tpl1745060424810.png", record_pos=(0.416, 0.02), resolution=(1280, 720)))
touch((1174,391))
wait(Template(r"tpl1745801921003.png", record_pos=(0.441, 0.205), resolution=(1280, 720)))
wait(Template(r"tpl1745801946768.png", record_pos=(0.452, -0.202), resolution=(1280, 720)))
touch((1085,656))
wait(Template(r"tpl1745060474121.png", record_pos=(-0.002, 0.188), resolution=(1280, 720)))
touch((653,599))
wait(Template(r"tpl1745060496932.png", record_pos=(0.232, -0.206), resolution=(1280, 720)))
touch((1231,33))
wait(Template(r"tpl1745060527453.png", record_pos=(-0.438, -0.252), resolution=(1280, 720)))
touch((84,119))
wait(Template(r"tpl1745801664369.png", record_pos=(-0.42, -0.253), resolution=(1280, 720)))
touch((58,297))
wait(Template(r"tpl1745060527453.png", record_pos=(-0.438, -0.252), resolution=(1280, 720)))
locate=(a,b)
touch(locate,duration=3.7)
当它在强化完一个仪器后,回到原来的位置进行重新扫描,但是如果当前页面没有垃圾桶的标志,它就会识别到右边那个原来强化过的仪器的垃圾桶图表,进行操作,实际上不是预期的操作
就像这样

**python 版本:** `python3.x`
**操作系统:** `Windows7 64bit`
**手机设备信息:**
- 手机型号: mumu模拟器12
- Android系统版本号: [e.g. Android 8.1]
- (别的信息)
**其他相关信息补充**
(例如在linux ubuntu16.04上运行异常,在windows上正常等信息。)
- AirtestIDE版本号:v1.2.17
我翻看过以前的关于exist的issue,发现在2019年的时候有类似的,当时的说法是没有类似功能,可以用target_pos 解决,但是我这个是这个页面不一定有这个图标,所以不适用, 所以我希望可以增加一个element来限制exist的识别范围
我已经用chatgpt和deepseek尝试过添加region和rect在template里面去限制,但是都会报错
当时的源代码if exists(Template(r"tpl1745060315000.png", record_pos=(0.005, -0.005), resolution=(1280, 720)),region=(126,119,779,618)):
报错的log
fda0556703b009dd'
[09:32:39][DEBUG] E:\script\TRY\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s 127.0.0.1:16480 get-state
[09:32:40][DEBUG] E:\script\TRY\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s 127.0.0.1:16480 wait-for-device
[09:32:40][DEBUG] E:\script\TRY\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s 127.0.0.1:16480 shell getprop ro.build.version.sdk
E:\script\TRY\AirtestIDE\airtest\core\android\cap_methods\adbcap.py:10: UserWarning: Currently using ADB screenshots, the efficiency may be very low.
warnings.warn("Currently using ADB screenshots, the efficiency may be very low.")
[09:32:40][DEBUG] E:\script\TRY\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s 127.0.0.1:16480 shell screencap -p
[09:32:40][DEBUG] E:\script\TRY\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s 127.0.0.1:16480 shell screencap -p
[09:32:41][ERROR] Traceback (most recent call last):
File "airtest\cli\runner.py", line 72, in runTest
File "E:\script\TRY\try\try.air\try.py", line 10, in
if exists(Template(r"tpl1745060315000.png", record_pos=(0.005, -0.005), resolution=(1280, 720)),region=(126,119,779,618)):
File "airtest\utils\logwraper.py", line 124, in wrapper
File "inspect.py", line 1346, in getcallargs
TypeError: exists() got an unexpected keyword argument 'region'
======================================================================
ERROR: runTest (app.widgets.code_runner.ide_launcher.AirtestIDECase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "airtest\cli\runner.py", line 75, in runTest
File "site-packages\six.py", line 703, in reraise
File "airtest\cli\runner.py", line 72, in runTest
File "E:\script\TRY\try\try.air\try.py", line 10, in
if exists(Template(r"tpl1745060315000.png", record_pos=(0.005, -0.005), resolution=(1280, 720)),region=(126,119,779,618)):
File "airtest\utils\logwraper.py", line 124, in wrapper
File "inspect.py", line 1346, in getcallargs
TypeError: exists() got an unexpected keyword argument 'region'
希望可以解决这个问题,打扰了
**截屏**
强烈建议带上截图,包括IDE本身的截图和后面的黑窗口的报错信息的截图(尽量完整)。
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.