使用python-webdri进行数据刮取

2024-06-10 02:30:54 发布

您现在位置:Python中文网/ 问答频道 /正文

codesample

我正在尝试使用Firefox-python-webdriver单击一个按钮

但每次出错时:

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: .pull-right show-toggle with-icon

我是不是漏了什么?在登录和几个步骤后,我在一个页面上,我需要点击下面的类名按钮达到。你知道吗

child = driver.find_element_by_class_name('pull-right show-toggle with-icon')
child.click()

还有别的办法吗?你知道吗


Tags: rightchildseleniumshowwithelementcommonfirefox
1条回答
网友
1楼 · 发布于 2024-06-10 02:30:54

根据提供的HTML,您可以使用以下代码单击您的按钮:

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait as wait

button = wait(driver, 10).until(EC.visibility_of_element_located((By.XPATH,"//a[@data-toggle-text='Hide details']")))
button.click()

相关问题 更多 >