[Python] How to set navigator.webdriver to undefined with Selenium for Firefox (geckodriver)

Discussão em 'Python' iniciado por Stack, Julho 31, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to set the navigator.webdriver variable in the Firefox browser to undefined using Selenium in Python.

    I have been able to successfully do this when using Chrome, but now I need to do the same thing using in Firefox. When using the Firefox webdriver, execute_cdp_cmd(...) does not exist.

    Does anyone know how to do the same thing using the firefox webdriver instead of the chrome webdriver?

    Please see the relevant code below.

    driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
    "source": """
    Object.defineProperty(navigator, 'webdriver', {
    get: () => undefined
    })
    """
    })

    Continue reading...

Compartilhe esta Página