Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select radio button with Selenium and Python

I am trying to select the radio button "Hitter". Could anyone help? I've tried a lot of different things, but keep getting "Message: element not visible".

Thanks!

enter image description here

like image 853
Josh Avatar asked Mar 16 '23 02:03

Josh


1 Answers

There are multiple ways to locate the radio input, here is the one using find_element_by_id():

radio = driver.find_element_by_id("ContentPlaceHolder1_HitterRadioButton")
radio.click()

Or, if you have problems with this approach, you can simulate a click via javascript:

radio = driver.find_element_by_id("ContentPlaceHolder1_HitterRadioButton")
driver.execute_script("arguments[0].click();", radio)
like image 200
alecxe Avatar answered Mar 23 '23 02:03

alecxe