Goal is to click on a checkbox on login page. I find the element by XPATH, but can't click on it.
>>> elem = driver.find_element_by_xpath("//input[@type='checkbox'][@name='conditions']")
>>> elem.is_displayed()
False
>>> elem.is_enabled()
True
>>> elem.get_attribute('outerHTML')
u'<input type="checkbox" class="custom-control-input" name="conditions">'
When I try elem.click(), exception occurs:
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible but element is clearly visible, since the page is loaded and I work from terminal.
Other error when I use different selector is:
driver.find_element_by_xpath('/html/body/div[2]/main/section/div/div[3]/div/div[1]/form/p[1]/label/input').click()
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <input type="checkbox" class="custom-control-input" name="conditions"> is not clickable at point (51, 549). Other element would receive the click: <span class="custom-control-description font-weight-regular">...</span>
I tried with injecting JavaScript but didn't work.
driver.execute_script("arguments[0].style.visibility = 'visible';",elem)
Any ideas how to work around this?