这个问题在这里已有答案:
我正在使用Python 3并使用Selenium单击浏览器中的单选按钮。我能够找到要点击的无线电元素。但是,当我做Element.click()
时,它给了我一个错误:
Message: unknown error: Element <Description of Element> is not clickable at point (340, 190).
Other element would receive the click: <Description of some other element>.
浏览器中显示的无线电元素是:
<input data-val="true" data-val-required="Required" id="Promoter" name="Type" onchange="Checkboxck('Promoter')" type="radio" value="Promoter" />
我找到这个无线电元素并点击它的代码是:
Registered_Project_RadioButton = browser.find_element_by_id("Promoter")
Registered_Project_RadioButton.click()
使用Actions类或Java Script Executor来实现此目的。
from selenium.webdriver.common.action_chains import ActionChains
Registered_Project_RadioButton = browser.find_element_by_id("Promoter")
ActionChains(browser).move_to_element(Registered_Project_RadioButton).click().perform()
要么
Registered_Project_RadioButton = browser.find_element_by_id("Promoter")
browser.execute_script("arguments[0].click();", Registered_Project_RadioButton)