Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to click radio button with selenium in python?

I want to select a radio button with selenium in python. I have tested with 3 solutions. Unfortunately it doesn’t work at all. Could you do me a favor and help me. I am totally beginner.
The URL:
https://biruni.tuik.gov.tr/disticaretapp/menu_ing.zul

enter image description here

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.ui import Select

driver = webdriver.Chrome('C:\Webdriver\chromedriver.exe')
driver.get('https://biruni.tuik.gov.tr/disticaretapp/menu_ing.zul')
time.sleep(2)
driver.maximize_window()
element = driver.find_element(by=By.XPATH,value='//*[contains(text(), "Product/Product Groups-Partner Country")]')                                                                                                            
element.click()
time.sleep(4)

# radio = driver.find_element_by_id("o1BQ41-real")
# radio.click()


# l=driver.find_element_by_xpath('//*[@id="o1BQ41-real"]')
# l.click()


# driver.find_element_by_css_selector("input#o1BQ41-real").click() 

time.sleep(10)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the same select by text to click on the radio button.

radio_element = driver.find_element(by=By.XPATH,value='//*[contains(text(), "Product/Partner Country")]')
radio_element.click()

This selects the desired element

enter image description here

or you can also select the element by id

radio_element = driver.find_element(by=By.XPATH,value='//span[@id="bKFP41"]')
radio_element.click()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading