4

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?

1
  • looks like an alert to tell the user that they have cookies turned off. You should probably just close that first. (Does it have a close button?) Commented Feb 28, 2020 at 18:32

3 Answers 3

1

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()
Sign up to request clarification or add additional context in comments.

Comments

1

It is also worth considering other scripts that might inject elements on the main page. Given the nature of the error, this look rather like one of those GDPR compliancy plugins that would force the alert on user. The best option is to dismiss it like Aayush mentioned and then go on with your script.

Comments

0

Bypass this by using javascript to carry out the click:

browser.execute_script(document.getElementById("slick-slide-control01").click())

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.