Selenium 中弃用 find_element_by_* 命令
早期版本的 Selenium Python 库支持使用 find_element_by_* 命令。然而,在最近的版本中,这些命令已被弃用。
错误消息:
在最新的 Selenium Python 库中使用 find_element_by_* 命令时,您可能会遇到以下情况错误消息:
DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
原因弃用:
弃用 find_element_by_* 命令的决定源于简化不同语言之间的 Selenium API 的目标。
解决方案:
要解决此问题,您应该改用 find_element() 方法而不是find_element_by_* 命令。
# Previous code button = driver.find_element_by_class_name("quiz_button") # Updated code from selenium.webdriver.common.by import By button = driver.find_element(By.CLASS_NAME, "quiz_button")
附加说明:
类似地,您需要更新其他 find_element_by_* 命令,如下所示:
Old Command | New Command |
---|---|
find_element_by_id() | find_element(By.ID, ...) |
find_element_by_name() | find_element(By.NAME, ...) |
find_element_by_link_text() | find_element(By.LINK_TEXT, ...) |
find_element_by_partial_link_text() | find_element(By.PARTIAL_LINK_TEXT, ...) |
find_element_by_tag_name() | find_element(By.TAG_NAME, ...) |
find_element_by_css_selector() | find_element(By.CSS_SELECTOR, ...) |
find_element_by_xpath() | find_element(By.XPATH, ...) |
注意:您还应该更新复数版本(find_elements_by_*) 相应地。
升级到 Selenium 4 时,请参阅 Selenium 升级指南,了解有关此更改和其他更改的更多信息。
以上是为什么 Selenium Python 库中不推荐使用 find_element_by_* 命令?的详细内容。更多信息请关注PHP中文网其他相关文章!

pythonuseshybridapprace,ComminingCompilationTobyTecoDeAndInterpretation.1)codeiscompiledtoplatform-Indepententbybytecode.2)bytecodeisisterpretedbybythepbybythepythonvirtualmachine,增强效率和通用性。

theKeyDifferencesBetnewpython's“ for”和“ for”和“ loopsare:1)” for“ loopsareIdealForiteringSequenceSquencesSorkNowniterations,而2)”,而“ loopsareBetterforConterContinuingUntilacTientInditionIntionismetismetistismetistwithOutpredefinedInedIterations.un

在Python中,可以通过多种方法连接列表并管理重复元素:1)使用 运算符或extend()方法可以保留所有重复元素;2)转换为集合再转回列表可以去除所有重复元素,但会丢失原有顺序;3)使用循环或列表推导式结合集合可以去除重复元素并保持原有顺序。

fasteStmethodMethodMethodConcatenationInpythondependersonListsize:1)forsmalllists,operatorseffited.2)forlargerlists,list.extend.extend()orlistComprechensionfaster,withextendEffaster,withExtendEffers,withextend()withextend()是extextend()asmoremory-ememory-emmoremory-emmoremory-emmodifyinginglistsin-place-place-place。

toInSerteLementIntoApythonList,useAppend()toaddtotheend,insert()foreSpificPosition,andextend()formultiplelements.1)useappend()foraddingsingleitemstotheend.2)useAddingsingLeitemStotheend.2)useeapecificindex,toadapecificindex,toadaSpecificIndex,toadaSpecificIndex,blyit'ssssssslorist.3 toaddextext.3

pythonlistsareimplementedasdynamicarrays,notlinkedlists.1)他们areStoredIncoNtiguulMemoryBlocks,mayrequireRealLealLocationWhenAppendingItems,EmpactingPerformance.2)LinkesedlistSwoldOfferefeRefeRefeRefeRefficeInsertions/DeletionsButslowerIndexeDexedAccess,Lestpypytypypytypypytypy

pythonoffersFourmainMethodStoreMoveElement Fromalist:1)删除(值)emovesthefirstoccurrenceofavalue,2)pop(index)emovesanderturnsanelementataSpecifiedIndex,3)delstatementremoveselemsbybybyselementbybyindexorslicebybyindexorslice,and 4)

toresolvea“ dermissionded”错误Whenrunningascript,跟随台词:1)CheckAndAdjustTheScript'Spermissions ofchmod xmyscript.shtomakeitexecutable.2)nesureThEseRethEserethescriptistriptocriptibationalocatiforecationAdirectorywherewhereyOuhaveWritePerMissionsyOuhaveWritePermissionsyYouHaveWritePermissions,susteSyAsyOURHomeRecretectory。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

SublimeText3汉化版
中文版,非常好用

SublimeText3 Linux新版
SublimeText3 Linux最新版