press a button with selenium python

Issue

enter image description here

I want the bot to click on male
But I don’t know how I tried to use this, but it didn’t work for me

driver.find_element_by_xpath("//input[@name='sex']").click()

I want a command to make the bot click on male in Python.

Solution

If you want to click on ‘Male’ radio-button try

driver.find_element_by_xpath("//label[.='Male']/following-sibling::input[@name='sex']").click()

Answered By – JaSON

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published