如何点击单选按钮(我读过之前的问题)python?
How to click on radio button(I read previous questions) python?
我有密码
<div>
<input type="radio" id="grupo1" name="grupo1" name="ControlGroupSearchView2$AvailabilitySearchInputSearchView2$RadioButtonMarketStructure" value="OneWay" />
<label>One-way</label>
</div>
我尝试了其他人建议使用的方法
args["OW"] = "input[type='radio'][value='OneWay']"
WebDriverWait(self.browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, args["OW"])))
self.browser.find_element_by_css_selector(self.args["OW"]).click()
但我收到错误:
selenium.common.exceptions.TimeoutException: Message:
因为找不到对象。
假设页面上没有 iframe
个元素。
我发现单选按钮的作用是单击相应的 label
而不是 input
:
wait = WebDriverWait(self.browser, 10)
one_way = wait.until(EC.visibility_of_element_located((By.XPATH, "//label[. = 'One-way']")))
one_way.click()
我有密码
<div>
<input type="radio" id="grupo1" name="grupo1" name="ControlGroupSearchView2$AvailabilitySearchInputSearchView2$RadioButtonMarketStructure" value="OneWay" />
<label>One-way</label>
</div>
我尝试了其他人建议使用的方法
args["OW"] = "input[type='radio'][value='OneWay']"
WebDriverWait(self.browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, args["OW"])))
self.browser.find_element_by_css_selector(self.args["OW"]).click()
但我收到错误:
selenium.common.exceptions.TimeoutException: Message:
因为找不到对象。
假设页面上没有 iframe
个元素。
我发现单选按钮的作用是单击相应的 label
而不是 input
:
wait = WebDriverWait(self.browser, 10)
one_way = wait.until(EC.visibility_of_element_located((By.XPATH, "//label[. = 'One-way']")))
one_way.click()