1
votes

I have a code, my problem - error, when I starting code. What's wrong ?

from selenium import webdriver

driver = webdriver.Chrome('D:\webdriver firefox\chromedriver.exe')

driver.get('https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407')

Working with radio button

status = driver.find_element_by_id('RESULT_RadioButton-8_0').is_selected() print(status)

driver.find_element_by_id('RESULT_RadioButton-8_0').click()

status = driver.find_element_by_id('RESULT_RadioButton-8_0').is_selected() print(status)

2
Post full code in question in formatted order. - ZF007
already solved the problem)) - Vyacheslav Bondarev
still post the complete code and post the answer as a separate answer (not in question) or remove question. - ZF007

2 Answers

2
votes

Here is the solution:

from selenium import webdriver

driver = webdriver.Chrome('C:/Users/XYZ/bin/chromedriver.exe')
driver.maximize_window()

driver.get('https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407')

status = driver.find_element_by_css_selector("[name='RESULT_RadioButton-7']").is_selected()
print(status)

driver.find_element_by_css_selector("[for='RESULT_RadioButton-7_0']").click()

status = driver.find_element_by_css_selector("[name='RESULT_RadioButton-7']").is_selected()
print(status)

Output :

False
True
0
votes

The problem is here:

Element <input type="radio" name="RESULT_RadioButton-8" class="multiple_choice" id="RESULT_RadioButton-8_0" value="Radio-0"> is not clickable at point (281, 538). Other element would receive the click: <label for="RESULT_RadioButton-8_0">

So you need to click the label, not the radio input. The label can be located using the following XPath expression:

//label[@for='RESULT_RadioButton-8_0']

So you need to change this line:

driver.find_element_by_id('RESULT_RadioButton-8_0').click()

to this one:

driver.find_element_by_xpath('//label[@for=\'RESULT_RadioButton-8_0\']').click()