AttributeError:'WebElement'对象没有属性'below'
创始人
2024-09-22 01:00:38
0

这个错误通常是因为selenium版本太低,缺少必要的包或模块,或者你正在使用的元素没有below属性。你可以尝试升级你的selenium版本,或使用必要的包或模块。如果你确保使用的元素具有below属性,请确保你的代码正确使用它。以下是一些可能导致此错误的示例代码:

#示例1:
elem = driver.find_element_by_class_name("my-class")
elem.below # 错误

#示例2:
elem = driver.find_element_by_xpath("//div[@class='my-class']")
elem.below() # 错误

#示例3:
from selenium.webdriver.common.action_chains import ActionChains

elem = driver.find_element_by_class_name("my-class")
action = ActionChains(driver)
action.move_to_element(elem).below() # 错误

解决这个问题的方法是使用与元素相关的正确方法。以下是相应的更正代码:

#示例1:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

elem = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "my-class")))
elem.location_once_scrolled_into_view
# 或者
from selenium.webdriver.common.keys import Keys
elem.send_keys(Keys.DOWN) # 或者任何其他向下滚动元素的方法

#示例2:
elem = driver.find_element_by_xpath("//div[@class='my-class']")
elem.location_once_scrolled_into_view
# 或者
from selenium.webdriver.common.keys import Keys
elem.send_keys(Keys.DOWN) # 或者任何其他向下滚动元素的方法

#示例3:
from selenium.webdriver.common.action_chains import ActionChains

elem = driver.find_element_by_class_name("my-class")
action = ActionChains(driver)
action.move_to_element(elem).click().perform()

相关内容

热门资讯

aapoker辅助!aapok... aapoker辅助!aapoker系统机制[透视]其实真的有挂(有挂工具)-哔哩哔哩1、不需要AI权...
wepokeai辅助!wepo... wepokeai辅助!wepoke软件俱乐部[透视]其实真的有挂(有挂工具)-哔哩哔哩;wepoke...
wepokeai辅助!wepo... wepokeai辅助!wepoke软件透明挂检测[辅助挂]其实真的有挂(有挂脚本)-哔哩哔哩,您好,...
wepower透视辅助!wpk... 自定义wepower系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管你...
wepokeai辅助!微扑克线... wepokeai辅助!微扑克线上代打[透视]其实真的有挂(有挂工具)-哔哩哔哩1.微扑克线上 ai辅...
德扑之星辅助挂!轰趴大菠萝十三... 德扑之星辅助挂!轰趴大菠萝十三水[辅助挂]其实真的有挂(有挂安装)-哔哩哔哩1、构建自己的微扑克辅助...
aapoker辅助工具!德州w... aapoker辅助工具!德州wpk德州真的[透视]其实真的有挂(有挂工具)-哔哩哔哩是一款可以让一直...
aapoker辅助工具!德州微... 1、aapoker辅助工具!德州微扑克辅助[透视]原来真的有挂(有挂神器)-哔哩哔哩。2、德州微扑克...
wepok软件透明挂!wpk德... 自定义wpk德州系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管你是想...
WPK透明挂!wepoke最新... WPK透明挂!wepoke最新下载地址[辅助挂]其实真的有挂(有挂工具)-哔哩哔哩;人气非常高,ai...