[Python] Selenium Click Intercepted by ui-widget-overlay Despite Removing Overlay and Modal

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    I'm automating a shipping form using Selenium and running into an issue where clicking a button fails because of a persistent overlay. The application uses jQuery UI for modals and overlays.

    The error I'm getting is:

    Message: element click intercepted: Element <a class="..."> is not clickable at point (...). Other element would receive the click: <div class="ui-widget-overlay ui-front"></div>


    Despite trying to remove this overlay and dialog using JavaScript, the click is still blocked or doesn't perform the desired action. Sometimes it looks like the page resets or the browser quits. Other times, I get a JavaScript error like:

    javascript error: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions...


    Or:

    Message: element not interactable


    Here's what I tried:

    # 1. Using Selenium's click directly
    try:
    driver.find_element(By.ID, 'ctl00_CPPC_ConfirmMessage_OSNR_btnOk').click()
    except Exception as e:
    print(f"❌ Failed: {e}")


    Fails with element click intercepted.

    # 2. Removing overlay and modal manually
    try:
    driver.execute_script("""
    let overlay = document.querySelector('.ui-widget-overlay');
    let dialog = document.querySelector('.ui-dialog');
    if (overlay) overlay.remove();
    if (dialog) dialog.remove();
    """)
    time.sleep(1)
    except Exception as e:
    print(f"❌ Overlay remove failed: {e}")


    Still gets intercepted. Sometimes the browser shuts down instantly.

    # 3. Clicking via JavaScript after removal
    try:
    driver.execute_script("""
    const btn = document.getElementById('ctl00_CPPC_ConfirmMessage_OSNR_btnOk');
    if (btn) btn.click();
    """)
    except Exception as e:
    print(f"❌ JavaScript click failed: {e}")


    Sometimes this throws Cannot read properties of null (reading 'click').

    # 4. Forcing the postback directly
    try:
    driver.execute_script("DoButtonPostBack('ctl00$CPPC$btnShip');")
    except Exception as e:
    print(f"❌ Postback failed: {e}")


    This can reload or completely close the page.

    # 5. Disabling jQuery dialog itself
    try:
    driver.execute_script("""
    if (window.jQuery) {
    jQuery.fn.dialog = function() { return this; };
    }
    """)
    except Exception as e:
    print(f"❌ jQuery disable failed: {e}")


    Still no effect. Overlay blocks action.

    Debug Insight:

    I logged success messages after each script like this:

    print("✅ Removed overlay")
    print("✅ Clicked OK button")


    But sometimes it prints these and still does nothing visible, or instantly quits. I even tried combinations of waiting and interacting. Example:

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'ctl00_CPPC_ConfirmMessage_OSNR_btnOk'))).click()


    Still failed.

    My environment:

    Chrome: 136.0.7103.114
    Selenium: 4.x
    Python: 3.11+
    chromedriver used


    What I need help with:


    1. A reliable way to remove the overlay and modal dialog completely.


    2. A working method to click the OK and Ship buttons afterward.


    3. Prevent the browser from closing or resetting after running the script.

    Any help would be appreciated. I've exhausted all reasonable ways I know. If you’ve dealt with persistent overlays or jQuery dialogs, your suggestions are welcome!


    Note: English is not my first language, so some parts of this post were helped by AI to better explain my issue. I’ve done my best to make everything clear.
    ​

    Continue reading...

Compartilhe esta Página