Selenium: element is not clickable because an other element obscures it

Viewed 348

I've been searching around the site but can not seem to find a fix that works for me. I am trying to click a button that should load more reviews.

driver.get("https://www.mediamarkt.nl/nl/product/_philips-essential-airfryer-xl-hd9260-90-1653991.html")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".bv-content-btn-pages-load-more"))).click()

Is the code I am using. This results in an error:

selenium.common.exceptions.ElementClickInterceptedException: Message: Element <button class="bv-content-btn bv-content-btn-pages bv-content-btn-pages-load-more bv-focusable" type="button"> is not clickable at point (674,670) because another element <div class="gdpr-cookie-layer gdpr-cookie-layer--show"> obscures it

I've tried getting the element and then clicking it:

element = driver.find_element_by_class_name('bv-content-btn-pages-load-more')
driver.execute_script("arguments[0].click();", element)

I also tried doing it using an action chain:

element = driver.find_element_by_class_name('bv-content-btn-pages-load-more')
ActionChains(driver).move_to_element(element).click().perform()

What is the actual issue here and how do I fix it?

1 Answers
WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
    (By.CSS_SELECTOR, '[class="gdpr-cookie-layer__btn gdpr-cookie-layer__btn--submit gdpr-cookie-layer__btn--submit--all"]'))).click()

WebDriverWait(driver, 20).until(EC.element_to_be_clickable(
    (By.CSS_SELECTOR, ".bv-content-btn-pages-load-more"))).click()

you have to first close the accept cookie dialogue , else selenium cannot click the load more element as the accept_cookie screen is in forground

Related