Josh
Josh

Reputation: 107

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

Upvotes: 4

Views: 8121

Answers (1)

alecxe
alecxe

Reputation: 474281

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)

Upvotes: 7

Related Questions