[英]Using Selenium Chromedriver with python how do i click this element?
I am want to be able to click this element in the Yandex account sign up page.我希望能够在 Yandex 帐户注册页面中单击此元素。
I am using Selenium Chromedriver with python.我正在使用 Selenium Chromedriver 和 python。
https://passport.yandex.com/registration/ https://passport.yandex.com/registration/
I have tried this code我试过这段代码
element = self.driver.find_element_by_class_name("toggle-link.link_has-no-phone").click()
webdriver.ActionChains(self.driver).move_to_element(element).click(element).perform()
but I get ElementClickInterceptedException.但我得到 ElementClickInterceptedException。
There's a element.click().perform()
有一个element.click().perform()
and you can also send a Return
key to the element您还可以向元素发送一个Return
键
from selenium.webdriver.common.keys import Keys
element = ... # get your element
element.send_keys(Keys.RETURN) # or send a left mouse click
It looks like the way you're finding the element is wrong, there are two classes for that element and you have tried to specify both -> find_element_by_class_name only takes one class attribute value.看起来您查找元素的方式是错误的,该元素有两个类,并且您尝试同时指定两者 -> find_element_by_class_name 仅采用一个 class 属性值。
So, this should work for you所以,这应该适合你
driver.find_element_by_class_name('link_has-no-phone').click()
Not sure why you are using ActionChains
here while you can simply click on the mentioned link.不知道你为什么在这里使用ActionChains
,而你可以简单地点击上面提到的链接。
Simplified code简化代码
self.driver.find_element_by_class_name("toggle-link.link_has-no-phone").click()
OR或者
element = self.driver.find_element_by_class_name("toggle-link.link_has-no-phone")
element.click()
OR或者
driver.find_element_by_css_selector('.toggle-link.link_has-no-phone').click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.