0

I am attempting to select a checkbox on a webpage using Selenium and Python using this line of code

self.driver.find_element_by_id('lg_1166').click()

but am getting this error message

Message: Element <input id="lg_1699" name="lg_1699" type="checkbox"> is not clickable at point (284,888) because another element <div class="col-12 text-center"> obscures it

Then, when I inspect that same webpage looking for <div class="col-12 text-center">, there is no matching HTML.

Here's the HTML of the page

I am unfamiliar with waits in Selenium and was wondering if anyone could help me resolve this issue.

Thanks!

booshwayne
  • 13
  • 3

1 Answers1

1

It is quite common in HTML for some elements to be visually placed over others in the UI rendering. When Selenium WebElement.click() is used, the visual dimension of the element on which click has to be performed is obtained and click is performed. If there is an element occupying the same visual space, error is thrown.

There are 2 possible solutions.

  1. You can wait until the element is clickable using the below explicit wait

    element = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, 'lg_1166')))
    element.click();
    
  2. Use javascript executor to click on the element. This would trigger a javascript click on the element by-passing the visual click.

    element = driver.find_element_by_id('lg_1166')
    driver.execute_script("arguments[0].click();", element)
    
StrikerVillain
  • 3,719
  • 2
  • 24
  • 41