python中appium 的NoSuchElementException錯誤 原因以及解決辦法

錯誤收集

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:57 ...
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 6.18s ========================
FAILED ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [100%]
demo.py:15 (TestAppium.test_study)
self = <demo.TestAppium object at 0x00000298250C8B90>

? ? def test_study(self):
> ? ? ? ele = self.app_do.find_element(by=AppiumBy.ID,value="com.microvirt.launcher2:id/tv_hint_name")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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 0x00000298252001A0>
response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"An element could not be located on the page u...ode_modules\\\\appium\\\\node_modules\\\\@appium\\\\base-driver\\\\lib\\\\basedriver\\\\commands\\\\find.ts:75:12)"}}'}

? ? 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.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#nosuchelementexception
E ? ? ? Stacktrace:
E ? ? ? NoSuchElementError: An element could not be located on the page using the given search parameters.
E ? ? ? ? ? at AndroidUiautomator2Driver.findElOrEls (C:\Users\Administrator\.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-android-driver\lib\commands\find.ts:86:11)
E ? ? ? ? ? at runMicrotasks (<anonymous>)
E ? ? ? ? ? at processTicksAndRejections (node:internal/process/task_queues:96:5)
E ? ? ? ? ? at AndroidUiautomator2Driver.findElOrElsWithProcessing (D:\Program\Util\nvm\nvm\v16.20.2\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\commands\find.ts:60:12)
E ? ? ? ? ? at AndroidUiautomator2Driver.findElement (D:\Program\Util\nvm\nvm\v16.20.2\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\commands\find.ts:75:12)

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

Process finished with exit code 1

錯誤分析

NoSuchElementException

使用appium定位的時候,沒有定位到該元素。

解決辦法

使用其他的定位方式

  • 使用ID定位
  • 檢查是不是定位方式出錯了
  • 使用class定位
  • 使用XPath定位
  • 或者使用名字定位
  • Css選擇器定位

運行結果

使用其他中方式定位可以解決。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/917427.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/917427.shtml
英文地址,請注明出處:http://en.pswp.cn/news/917427.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mybatis-plus從入門到入土(四):持久層接口之BaseMapper和選裝件

大家好&#xff0c;今天繼續更新MybatisPlus從入門到入土系列&#xff0c;上一次的持久層接口還沒講完&#xff0c;只講了IService接口&#xff0c;今天我們繼續來講一下。 BaseMapper BaseMapper中的方法也比較簡單&#xff0c;都是增刪改查的基礎API&#xff0c;不知道大家還…

數組和指針的關系

在 C 語言中&#xff0c;?指針和數組有著非常緊密的聯系&#xff0c;但它們本質上是 ?不同的概念。理解它們的關系是掌握 C 語言內存操作的關鍵。下面我會從多個角度幫你梳理 ?指針和數組的直接聯系&#xff0c;并解釋它們的異同點。1. 數組和指針的本質區別?概念本質存儲方…

AI大模型探索之路-實戰篇:智能化IT領域搜索引擎之github網站在線搜索

系列篇章?? No. 文章 1 AI大模型探索之路-實戰篇:智能化IT領域搜索引擎的構建與初步實踐 2 AI大模型探索之路-實戰篇:智能化IT領域搜索引擎之GLM-4大模型技術的實踐探索 3 AI大模型探索之路-實戰篇:智能化IT領域搜索引擎之知乎網站數據獲取(初步實踐) 4 AI大模型探索之路…

從0到1學PHP(十二):PHP 框架入門與項目實戰

目錄一、主流 PHP 框架介紹1.1 Laravel1.2 ThinkPHP1.3 Yii1.4 框架的優勢二、框架基本使用&#xff08;以 Laravel 為例&#xff09;2.1 框架的安裝與配置2.2 路由定義、控制器創建、視圖渲染2.3 數據庫操作&#xff08;ORM 的使用&#xff09;三、小型項目實戰3.1 項目需求分…

MPLS LSP

一、概述上一章我們已經介紹過,LSP是MPLS報文在MPLS網絡中轉發時經過的路徑,可以看作是由報文傳輸方向節點為對應FEC分配的MPLS入標簽組成的,因為每臺設備上為每個FEC分配的入標簽是唯一 的&#xff0c;并與由下游節點為本地節點上該FEC分配的出標簽建立映射關系&#xff0c; 所…

圖像、視頻、音頻多模態大模型中長上下文token壓縮方法綜述

多模態大模型MLLMs 能夠處理高分辨率圖像、長視頻序列和冗長音頻輸入等復雜上下文&#xff0c;但自注意力機制的二次復雜度使得大量輸入 token 帶來了巨大的計算和內存需求。 如下圖&#xff0c;上&#xff1a;圖像、視頻和音頻數據類型可以在其表示維度上進行擴展&#xff0c;…

Spring MVC 九大組件源碼深度剖析(一):MultipartResolver - 文件上傳的幕后指揮官

文章目錄一、為什么從 MultipartResolver 開始&#xff1f;二、核心接口&#xff1a;定義文件上傳的契約三、實現解析&#xff1a;兩種策略的源碼較量1. StandardServletMultipartResolver&#xff08;Servlet 3.0 首選&#xff09;2. CommonsMultipartResolver&#xff08;兼容…

stm32是如何實現電源控制的?

STM32的電源控制主要通過內置的電源管理模塊&#xff08;PWR&#xff09;實現&#xff0c;涵蓋電壓調節、功耗模式切換和電源監控等功能。以下是其核心機制及實現方式&#xff1a;??1. 電源架構與供電區域??STM32的電源系統分為多個供電區域&#xff0c;各司其職&#xff1…

《R for Data Science (2e)》免費中文翻譯 (第3章) --- Data transformation(1)

寫在前面 本系列推文為《R for Data Science (2)》的中文翻譯版本。所有內容都通過開源免費的方式上傳至Github&#xff0c;歡迎大家參與貢獻&#xff0c;詳細信息見&#xff1a; Books-zh-cn 項目介紹&#xff1a; Books-zh-cn&#xff1a;開源免費的中文書籍社區 r4ds-zh-cn …

rclone、rsync、scp使用總結

數據同步工具使用總結【rclone、rsync、scp】一、數據處理背景二、數據處理方法對比1、數據關系梳理2、不同工具處理方法3、經驗總結三、工具擴展知識1、rclone工具介紹&#xff08;1&#xff09;、rclone概述&#xff08;2&#xff09;、安裝工具及配置本地文件遷移到云上服務…

用latex+vscode+ctex寫畢業論文

文章目錄前言一、安裝latex二、安裝ctex包三、更新ctex包四、使用ctex文檔類前言 用latexvscodectex寫畢業論文。&#xff08;英文論文不用安裝ctex&#xff09; CTEX 宏集是面向中文排版的通用 LATEX 排版框架&#xff0c;為中文 LATEX 文檔提供了漢字輸出支持、標點壓縮、字…

深度學習·mmsegmentation基礎教程

mmsegmentation的使用教程 mmsegmentation微調方法總結 自定義自己的數據集&#xff1a;mmsegmentation\configs\_base_\datasets\ZihaoDataset_pipeline.py注冊&#xff1a;mmsegmentation\configs\_base_\datasets\__init__.py定義訓練和測試的pipeline&#xff1a;mmsegme…

InfluxDB 與 Node.js 框架:Express 集成方案(二)

四、優化與注意事項 &#xff08;一&#xff09;性能優化技巧 連接池管理&#xff1a;使用連接池可以有效減少創建和銷毀數據庫連接的開銷。在 Node.js 中&#xff0c;可以借助influx模塊結合第三方連接池庫&#xff0c;如generic-pool來實現連接池的管理 。通過設置連接池的…

單位長度上的RC參數

1inch1000mil25.4mm2.54cm 使用SI9000計算導線上電容電感參數并使用Q2D進行仿真驗證。使用SI9000建立一個阻抗為50歐的微帶線模型&#xff0c;后對該模型進行1GHz頻域計算 通過計算得到結果&#xff0c;可知1GHz頻率下單位傳輸線上的RLGC參數使用SI9000計算好單位長度上的RLGC參…

基于Dockerfile 部署一個 Flask 應用

Docker 與 Python&#xff1a;容器化部署應用&#xff0c;實現快速發布與彈性伸縮 以下是一個簡單的 Flask 應用 # app.py - 一個簡單的Flask應用 from flask import Flask import osapp Flask(__name__)app.route("/") def hello():env os.environ.get(FLASK_ENV,…

DFT設計中的不同階段介紹

在DFT&#xff08;Design for Test&#xff0c;可測試性設計&#xff09;軟件開發中&#xff0c;針對設計檢測的完整流程通常包含Setup&#xff08;設置&#xff09;、Analysis&#xff08;分析&#xff09;、Insertion&#xff08;插入&#xff09;和Verification&#xff08;…

自動化測試準備工作:概念篇

自動化 什么是自動化? 超市的自動閘門&#xff0c;不需要手動的開門關門生活中的自動動化案例有效的減少了人力的消耗&#xff0c;同時也提高了生活的質量。 軟件自動化測試同理&#xff0c;通過編寫自動化測試程序&#xff08;減少人力和時間的消耗&#xff0c;提高軟件的…

每日主題切換網頁:用純前端技術打造隨心情變化的動態界面

&#x1f3a8; 每日主題切換網頁&#xff1a;用純前端技術打造隨心情變化的動態界面 項目地址&#xff1a;https://github.com/hhse/daily-theme-switcher 在線演示&#xff1a;https://hhse.github.io/daily-theme-switcher 這里寫目錄標題&#x1f3a8; 每日主題切換網頁&…

TOPSIS(Technique for Order Preference by Similarity to Ideal Solution )簡介與簡單示例

前言 提醒&#xff1a; 文章內容為方便作者自己后日復習與查閱而進行的書寫與發布&#xff0c;其中引用內容都會使用鏈接表明出處&#xff08;如有侵權問題&#xff0c;請及時聯系&#xff09;。 其中內容多為一次書寫&#xff0c;缺少檢查與訂正&#xff0c;如有問題或其他拓展…

uniapp 富文本rich-text 文本首行縮進和圖片居中

1. uniapp 富文本rich-text 文本首行縮進和圖片居中 1.1. rich-text 文本首行縮進使用 rich-text 組件渲染html格式的代碼&#xff0c;常常因為不能自定義css導致文本不能縮進&#xff0c;以及圖片不能居中等問題&#xff0c;這里可以考慮使用js的replace方法&#xff0c;替換…