-2

There are 2 radioboxes "Yes" and "No", the "No" is selected by default and I want to click the "Yes" one but keep getting the same error

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="radio" id="si_notificar" name="notificar" value="1" class="custom-control-input notificar"> is not clickable at point (361, 308). Other element would receive the click: <label class="custom-control-label text-sm" for="si_notificar">...</label>

I have tried by xpath, by id, using WeDriverWait (I'm using time.sleep right now with an extended time just to be sure that the time isn't the problem) but it gives me the same error.

YES radio box:

<input type="radio" id="si_notificar" name="notificar" value="1" class="custom-control-input notificar"> ```

NO radio box:

<input type="radio" id="no_notificar" name="notificar" value="0" class="custom-control-input notificar" checked="">

My code:

time.sleep(15)
driver.find_element(By.ID,"si_notificar").click()
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

-1

ElementClickInterceptedException occured while clicking on:

<input type="radio" id="si_notificar" name="notificar" value="1" class="custom-control-input notificar">

as ideally while dealing with checkbox, radiobutton, etc, instead of targeting the <input> you need to target the <label> element preferably using the for attribute.


Solution

To click on the assiciated with text as Yes you can use either of the following locator strategies:

  • Using css_selector:

    driver.find_element(By.CSS_SELECTOR, "label[for='si_notificar']").click()
    
  • Using xpath:

    driver.find_element(By.XPATH, "//label[@for='si_notificar']").click()
    

Ideally, you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategies:

  • Using cssSelector:

    new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("label[for='si_notificar']"))).click();
    
  • Using xpath:

    new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//label[@for='si_notificar']"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352