当前位置: 首页 > 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.dtcms.com/a/310470.html

相关文章:

  • 在PyCharm中将现有Gitee项目重新上传为全新项目
  • WordPress 前端显示英文,后台显示中文的设置
  • CH7216A USB Type C上的 DisplayPort 转 HDMI 2.0 转换器【CH7216A-BF】
  • JSON 对象在浏览器中顺序与后端接口返回不一致的问题
  • 基于cygwin或msmy的windows环境下的jupyterlab的C内核搭建
  • Lipschitz连续函数
  • Flutter 替换镜像源
  • 牛客——接头密匙
  • .net依赖注入框架 Autofac和MEF的对比
  • 如何在企业微信中打开外部网页或者自己开发的本地网页
  • vue+ts 基础面试题 (四)
  • 『React』 组件通信全攻略
  • 工业环境中无人叉车安全标准深度解析
  • django的数据库原生操作sql
  • 洛谷做题3:P5711 【深基3.例3】闰年判断
  • 浪潮信息PMO负责人时军受邀为PMO大会主持人
  • 如何最简单、通俗地理解线性回归算法? 线性回归模型在非线性数据上拟合效果不佳,如何在保持模型简单性的同时改进拟合能力?
  • 【C++】类和对象 上
  • JP3-3-MyClub后台后端(二)
  • JavaScript 深拷贝:从基础到完美实现
  • 使用Jeecg低代码平台实现计划管控系统建设方案--1项目前后端搭建
  • 《义龙棒球科普》棒球是韩国的国球吗·棒球1号位
  • 德国威乐集团亚太中东非洲PMO负责人和继明受邀为PMO大会主持人
  • 逻辑回归算法 银行贷款资格判断案例,介绍混淆矩阵与正则化惩罚
  • Google机器学习基础(语言模型)
  • 第13届蓝桥杯Python青少组选拔赛(STEMA)2021年8月真题
  • osloader!DoGlobalInitialization函数分析之HW_CURSOR--NTLDR源代码分析之设置光标
  • Python编程基础与实践
  • Linux 用户与组管理及权限委派
  • 自由学习记录(75)