0

I am getting following error while trying to click on radio button using selenium Webdriver in python

ElementClickInterceptedException: Message: element click intercepted: Element 
<input name="gender" required="" type="radio" id="gender-radio-1" class="custom-control-input" value="Male"> 
is not clickable at point (532, 370). Other element would receive the click: <label title="" for="gender-radio-1" class="custom-control-label">...</label>
  (Session info: chrome=88.0.4324.182)

Below is the my code page url:https://demoqa.com/automation-practice-form

from selenium import webdriver
driver = webdriver.Chrome(executable_path = 'chromedriver')
driver.maximize_window()
driver.get('https://demoqa.com/automation-practice-form')
btn = driver.find_element_by_xpath('//input[@name = "gender"]')
driver.implicitly_wait(7)
btn.click()

Is there any way to work around this? I have tried multiple things but unable to perform the task.

rogercake
  • 63
  • 7

1 Answers1

3

Try forcing the click by executing javascript:

btn = driver.find_element_by_xpath('//input[@name = "gender"]')
driver.execute_script("arguments[0].click();", btn)

Separately, consider using WebDriverWait instead of implicit waits.

0buz
  • 3,443
  • 2
  • 8
  • 29
  • thanks, it worked.Could you please explain why we used arguments[0] – rogercake Feb 19 '21 at 16:38
  • That's javascript syntax. Think of it as - the first argument you pass to the script is your `btn`. Others have [explained it better than me](https://stackoverflow.com/questions/52273298/what-is-arguments0-while-invoking-execute-script-method-through-webdriver-in) – 0buz Feb 19 '21 at 17:09