Selenium + Python + Unittest:Error message when executing Test "Other element would receive the click"

Mornon :

Details: In my current project I am writing test cases about Python and Selenium within Magento. In doing so I request a slide surface (button).

Request:

def test_pagebuilder_slide_button_pagebuilder_button_primary(self):
        driver = self.driver
        driver.get("my_webseite.de")
        time.sleep(15)
        try: driver.find_element_by_id("slick-slide-control01").click()
        except AssertionError as e: self.verificationErrors.append(str(e)) 
        time.sleep(15)

Now I get the message that the test works because another area would prevent this. And this although I directly after the ID search and this is available.As first aid I had also taken a break, maybe that's why?

Error message:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button type="button" role="tab" id="slick-slide-control01" aria-controls="slick-slide01" aria-label="... of 2" tabindex="-1">2</button> is not clickable at point (517, 612). Other element would
receive the click: <div role="alertdialog" tabindex="-1" class="message global cookie" id="notice-cookie-block" style="">...</div>

Do you have any idea how I can avoid this?

0buz :

One common instance for this error is when the element is not visible on the page, as in you might, for example, need to scroll to reach that element. If that's the case ActionChains should do the trick:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "slick-slide-control01")))
ActionChains(driver).move_to_element(driver.find_element_by_id("slick-slide-control01")).click().perform()

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=28223&siteId=1