python selenium element not interactable when bot tries to click agreement button

Viewed 191
<input id="agreement-input-mobile" class="agreement-input" type="checkbox" name="agreement" aria-describedby="agreement-content">

im trying to automate a certain task but it needs to click an agreement button but every time I try to select it I get this error

 selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=87.0.4280.67)

here's what my line of code looks like

driver.find_element_by_name('agreement').click()
2 Answers

I wouldn't recommend to find elements by name. Use ID or xpath. So change driver.find_element_by_name('agreement').click() to driver.find_element_by_id('agreement-input-mobile').click()

Instead of .click() method, you can try another way like this:

  1. Using ActionChains:

    #following import
    from selenium.webdriver import ActionChains
    
    
    element = driver.find_element_by_id('agreement-input-mobile')
    action = ActionChains(driver)
    action.move_to_element(element).click(element).perform()
    
  2. Using .execute_script:

    element = driver.find_element_by_id('agreement-input-mobile')
    driver.execute_script("arguments[0].click();", element)
    
Related