【发布时间】:2021-12-03 20:04:21
【问题描述】:
我正在使用 Selenium 和 Python 来尝试点击网页上的按钮,如下所示:
<div id="home" class="sc-gKAaRy bGevZe"><h1 tabindex="-1" id="home_children_heading" class="sc-fujyAs fxSjMq">Vérification</h1>
<p id="home_children_body" class="sc-pNWdM hbrIBL">Veuillez résoudre l’énigme pour que nous sachions que vous n’êtes pas un robot.</p>
<a href="#" aria-describedby="descriptionVerify" id="home_children_button" class="sc-bdnxRM gonizE sc-kEqXSa duYBxC">Suivant</a>
<div id="descriptionVerify" class="Home__StyledHiddenAnnouncement-sc-lzg094-0 kfyjkn">
Défi visuel.Les utilisateurs de lecteurs d'écran doivent utiliser le défi audio ci-dessous.</div></div>
我尝试了许多解决方案,例如单击 Xpath 和 href,但没有一个是有效的,你能帮帮我吗? 这是我尝试使用它的代码:
xPath = '//*[@id="home_children_button"]'
driver.find_element_by_xpath(xPath).click()
#With other Xpath
xPath = 'xPath = "//input[contains(@type,'submit')][contains(@id,'home_children_button')][contains(.,'Suivant')]"'
driver.find_element_by_xpath(xPath).click()
我需要你的帮助,拜托!
【问题讨论】:
-
它是否会抛出任何错误,说明未找到该元素?如果是,那么您的 xpath 可能是错误的。
标签: python selenium button click