python:selenium:单选按钮

时间:2017-06-24 16:46:02

标签: python selenium

我在使用selenium和python时无法单击单选按钮,我收到以下错误:

  

selenium.common.exceptions.ElementNotInteractableException:消息:

这是我的代码:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.keys import Keys

import time,os
binary = FirefoxBinary(r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe")
driver = webdriver.Firefox(firefox_binary=binary)
driver.get("https://www.krogerfeedback.com/?AspxAutoDetectCookieSupport=1")

time.sleep(2)

driver.find_element_by_xpath("//select[@id='InputMonth']/option[@value='06']").click()
driver.find_element_by_xpath("//select[@id='InputDay']/option[@value='23']").click()
driver.find_element_by_xpath("//select[@id='InputHour']/option[@value='12']").click()
driver.find_element_by_xpath("//select[@id='InputMinute']/option[@value='15']").click()
driver.find_element_by_xpath("//select[@id='InputMeridian']/option[@value='PM']").click()

temp= driver.find_element_by_id("CN1")
temp.send_keys('035')

temp= driver.find_element_by_id("CN2")
temp.send_keys('211')

temp= driver.find_element_by_id("CN3")
temp.send_keys('36')


temp= driver.find_element_by_id("CN4")
temp.send_keys('577')

temp= driver.find_element_by_id("CN5")
temp.send_keys('502')

temp= driver.find_element_by_id("CN6")
temp.send_keys('538')

temp= driver.find_element_by_id("NextButton")
temp.send_keys(Keys.ENTER)

time.sleep(5)

i = driver.find_element_by_xpath("//*[@type='radio']")
i.click()



temp= driver.find_element_by_id("NextButton")
temp.send_keys(Keys.ENTER)

1 个答案:

答案 0 :(得分:0)

我检查了网站,单选按钮无法互动。所以,我选择了上面的元素并且它可以工作,所以将代码更改为:

i = driver.find_element_by_xpath("//span[@class='radioBranded']")
i.click()