Skip to content Skip to sidebar Skip to footer

Element Not Clickable Since Another Element Obscures It In Python

I am trying to automate an access point web configuration. During this, I get a pop up (kind of an overlay with 'Yes' and 'No') which i want to click on The HTML code for the overl

Solution 1:

As per your question and the HTML you have shared, you need to induce WebDriverWait for the desired element to be clickable and you can use the following solution:

#to click on Yes button
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='warning-content dialog-content text-orphan' and contains(.,'Security Mode is disabled')]//following::div[1]//button[@class='submit']"))).click()
# to click on No button
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='warning-content dialog-content text-orphan' and contains(.,'Security Mode is disabled')]//following::div[1]//button[@class='cancel']"))).click()

Note : You have to add the following imports :

from selenium.webdriver.support.uiimportWebDriverWaitfrom selenium.webdriver.common.byimportByfrom selenium.webdriver.supportimport expected_conditions asEC

Solution 2:

You can Replace click event with action class

Using Action Class :

from selenium.webdriver.common.action_chains importActionChainsactions= ActionChains(driver)
actions.move_to_element("Your Web Element").click().perform()

Post a Comment for "Element Not Clickable Since Another Element Obscures It In Python"