首页 > 其他分享 >appium报错AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

appium报错AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

时间:2023-06-29 10:47:02浏览次数:44  
标签:WebDriver appium element 报错 id AppiumBy find

解决方法:

from appium.webdriver.common.appiumby import AppiumBy # 导入AppiumBy
search = driver.find_element(AppiumBy.ID,"com.android.settings:id/search") # 编写格式:driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='accessibility_id')

思考流程:
1.敲代码时,编辑器已经标黄提示无find_element_by_id,当时以为是敲错,复制了正确的代码运行,报“AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'”
2.查看网上解决方案,有人提到现在的版本不支持find_element_by_id,目前写法为driver.find_element(By.ID,"com.android.settings:id/search"),修改后运行,仍然报错
3.ctrl+查看find_element方法,直接复制注释中的driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='accessibility_id'),AppiumBy报错
4.找到https://blog.csdn.net/fsafd3321/article/details/127096420博客中的解决方法,尝试后,能成功运行。但是解决思路中,提到的文件中搜索关键词这步不会
5.反推第三步,应该这样看,ctrl+查看find_element方法,然后由于AppiumBy报错,应该再点击查看find_element中的AppiumBy类,或全文搜索AppiumBy可看到导入的
from appium.webdriver.common.appiumby import AppiumBy




参考博客:
https://www.cnblogs.com/liuyuelinfighting/p/15677738.html
https://blog.csdn.net/fsafd3321/article/details/127096420

标签:WebDriver,appium,element,报错,id,AppiumBy,find
From: https://www.cnblogs.com/ly19/p/17040140.html

相关文章

  • 使用vue cli 5.0 在vscode中运行vue命令报错
       1、运行 vue--version  报错  2、在cmd命令行执行 vue--version 正常  3、在终端中输入  get-ExecutionPolicy,查看当前权限  4、执行 set-executionpolicyremotesigned  命令设置为可用模式,但是报错  5、使用管理员打开powe......
  • 离线安装mysql报错解决方法:/usr/sbin/mysqld: error while loading shared libraries:
    Linux:centos7.664位mysql:5.6使用离线方式安装:rpm-ivh--nodepsmysql*,执行systemctlstartmysqld.service发现启动不了,通过vi/var/log/mysql.log看到如下关键字:libraries:libaio.so.1,之前也是按照网上帖子各种修改都没有解决问题,详细报错如下:/usr/sbin/mysqld:error......
  • jmeter通过jmeter -n -t Script2.jmx命令压测导出HTML报告报错【杭州多测师_王sir】
    压测命令:jmeter-n-tScript2.jmx -lreport.jtl-e-o/cms/report/报错:Creatingsummariser<summary>ErrorinNonGUIDriverjava.lang.IllegalArgumentException:Reportgenerationrequirescsvoutputformat,check'jmeter.save.saveservice.output_forma......
  • jmeter 导入jmx脚本时,报错ConnotResolveClassException
     问题:使用V3.1版本的jmeter写了一个脚本,然后电脑上装了一个V5.1.1版本的jmeter,将脚本到如到jmeter上时,报错 ConnotResolveClassException,具体报错如下图所示,导入另外一个脚本并没有报错原因:如下图所示,报错内容是:kg.apc.jmetere.timers.VariableThroughputTimer.意思......
  • 修改xampp中的mysql的密码报错,ERROR 1348 (HY000): Column 'Password' is not updatab
    xampp中的mysql(MariaDB)默认密码为空,进入mysql的bin目录,输入mysql-uroot-p,回车,无密码登录:查看所有数据库,选择mysql数据库:showdatabases;usemysql;使用update语句修改密码报错:ERROR1348(HY000):Column‘Password’isnotupdatable使用如下命令修改密码,并没有效果:使......
  • ESLint 安装使用及报错处理
    安装ESlint并初始化配置//第一种//全局安装ESLintnpmieslint-g//生成配置文件//根据自己的项目需求进行设置(yes/no)eslint--init√HowwouldyouliketouseESLint·problems√Whattypeofmodulesdoesyourprojectuse·esm√Whichframework......
  • nextjs项目引入vconsole报错处理:ReferenceError: window is not defined
    引入文件(nextjs项目):importVconsolefrom'vconsole'报错: 处理:letVconsoleif(typeofwindow!=='undefined'){Vconsole=require('vconsole')}打开调试:if(typeofwindow!=='undefined'){//加了一个打开调试......
  • docker报错:Error response from daemon: driver failed programming external connect
    重启docker-compose时,nginx服务报错。报错信息:Errorresponsefromdaemon:driverfailedprogrammingexternalconnectivityonendpointlikeshop-nginx(f0a809481f5016e6f7ca6e1ed826b0676d5523b15f2954a2d22c03c12a89567d):Bindfor0.0.0.0:80failed:portisalr......
  • Unable to load '@webpack-cli/serve' command 报错问题
    [webpack-cli]Unabletoload'@webpack-cli/serve'command[webpack-cli]TypeError:options.forEachisnotafunctionatWebpackCLI.makeCommand(E:\vue-workspace\change-row-color\node_modules\webpack-cli\lib\webpack-cli.js:173:21)atS......
  • 全栈测试开发系列----WebDriver API及对象识别技术(一)
    前言:WebDriverAPI相比于之前的selenium-RCAPI而言,不仅解决了一些相关的限制,还使得接口更加简洁,同时更好的支持了页面本身不重新加载而页面元素发生变化的动态网页,所以WebDriverAPI的实现目的不仅是提供一个良好的面向对象API,而且对Web应用程序测试过程中所产生的问题......