当前位置: 首页 > news >正文

python中appium

错误搜集

D:\Program\Util\python.exe "D:/Program/myUtil/PyCharm 2024.3.5/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py" --target demo.py::TestAppium 
Testing started at 15:51 ...
Launching pytest with arguments demo.py::TestAppium --no-header --no-summary -q in C:\Users\Administrator\PycharmProjects\pyAppium

============================= test session starts =============================
collecting ... collected 1 item

demo.py::TestAppium::test_study 

======================== 1 failed, 3 warnings in 5.41s ========================
FAILED                                   [100%]
demo.py:15 (TestAppium.test_study)
self = <demo.TestAppium object at 0x0000025BC0300A50>

    def test_study(self):
>       self.app_do.find_element(by=AppiumBy.ID,value="")

demo.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
D:\Program\Util\Lib\site-packages\selenium\webdriver\remote\webdriver.py:922: in find_element
return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
D:\Program\Util\Lib\site-packages\selenium\webdriver\remote\webdriver.py:454: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <appium.webdriver.errorhandler.MobileErrorHandler object at 0x0000025BC04301A0>
response = {'status': 500, 'value': '{"value":{"error":"unknown error","message":"An unknown server-side error occurred while pro...20.2\\\\node_modules\\\\appium\\\\node_modules\\\\@appium\\\\base-driver\\\\lib\\\\protocol\\\\protocol.js:487:57)"}}'}

    def check_response(self, response: Dict[str, Any]) -> None:
"""
https://www.w3.org/TR/webdriver/#errors
"""
payload = response.get('value', '')
if isinstance(payload, dict):
payload_dict = payload
else:
try:
payload_dict = json.loads(payload)
except (json.JSONDecodeError, TypeError):
return
if not isinstance(payload_dict, dict):
return
value = payload_dict.get('value')
if not isinstance(value, dict):
return
error = value.get('error')
if not error:
return

message = value.get('message', error)
stacktrace = value.get('stacktrace', '')
# In theory, we should also be checking HTTP status codes.
# Java client, for example, prints a warning if the actual `error`
# value does not match to the response's HTTP status code.
exception_class: Type[sel_exceptions.WebDriverException] = ERROR_TO_EXC_MAPPING.get(
error, sel_exceptions.WebDriverException
)
if exception_class is sel_exceptions.WebDriverException and message:
if message == 'No such context found.':
exception_class = appium_exceptions.NoSuchContextException
elif message == 'That command could not be executed in the current context.':
exception_class = appium_exceptions.InvalidSwitchToTargetException

if exception_class is sel_exceptions.UnexpectedAlertPresentException:
raise sel_exceptions.UnexpectedAlertPresentException(
msg=message,
stacktrace=format_stacktrace(stacktrace),
alert_text=value.get('data'),
)
>       raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
E       selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Must provide a selector when finding elements
E       Stacktrace:
E       UnknownError: An unknown server-side error occurred while processing the command. Original error: Must provide a selector when finding elements
E           at getResponseForW3CError (D:\Program\Util\nvm\nvm\v16.20.2\node_modules\appium\node_modules\@appium\base-driver\lib\protocol\errors.js:1143:9)
E           at asyncHandler (D:\Program\Util\nvm\nvm\v16.20.2\node_modules\appium\node_modules\@appium\base-driver\lib\protocol\protocol.js:487:57)

D:\Program\Util\Lib\site-packages\appium\webdriver\errorhandler.py:125: WebDriverException

Process finished with exit code 1

错误分析

>       self.app_do.find_element(by=AppiumBy.ID,value="")

看这里这行代码,发现忘记填写value中的id值了。

解决办法

补充value中定位的id值

android:id/icon

修改代码部分,填写id值

运行结果

http://www.lryc.cn/news/606813.html

相关文章:

  • K8S周期性备份etcd数据实战案例
  • 精通分类:解析Scikit-learn中的KNN、朴素贝叶斯与决策树(含随机森林)
  • 应用药品注册证识别技术,为医药行业的合规、高效与创新发展提供核心驱动力
  • 智能图书馆管理系统开发实战系列(四):后端C++ DLL开发与模块化设计
  • Dify版本升级实操
  • 体育直播系统搭建:核心数据详细接入指南
  • 网络编程-加密算法
  • CCleaner是否被过誉了?C盘满了怎么办?用ccleaner清除C盘垃圾,3款电脑系统磁盘清理和优化软件
  • 应用Builder模式在C++中进行复杂对象构建
  • Vue与Ajax快速入门
  • GXP6040K压力传感器可应用于医疗/汽车/家电
  • Python Flask框架Web应用开发完全教程
  • 【stm32】GPIO
  • 第3章 AB实验的统计学知识
  • 从Web2.0到Web3.0:社交参与方式的重塑与延伸
  • 报错[Vue warn]: Failed to resolve directive: else如何解决?
  • Linux9 root密码修改
  • 数据结构第5问:什么是队列?
  • 【科普】怎么理解Modbus、TCP、UDP
  • C++入门自学Day4-- c++类与对象(友元)
  • 《软件测试与质量控制》实验报告一 测试用例设计
  • 新一代PLC控制软件平台EsDA-AWStudio
  • Linux文件系统理解2
  • Python爬虫库性能与选型实战指南:从需求到落地的全链路解析
  • PendingIntent的flag和原理解析
  • 如何使用淘宝开放平台API获取商品详细信息?
  • Docker设置容器时间
  • 通过pendingIntent启动activity被block问题
  • 网站QPS多少才算高并发
  • TOGAF指南1