无法在浏览器中单击radio元素(使用Python 3和Selenium)[重复]

问题描述 投票:2回答:1

我正在使用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(&#39;Promoter&#39;)" type="radio" value="Promoter" />

我找到这个无线电元素并点击它的代码是:

Registered_Project_RadioButton = browser.find_element_by_id("Promoter")
Registered_Project_RadioButton.click()
python-3.x selenium selenium-webdriver selenium-chromedriver
1个回答
0
投票

使用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)
© www.soinside.com 2019 - 2024. All rights reserved.