10

I didn't make any changes to my python selenium program and it worked fine 3 days ago. Now when i try to use it i get:

Browsing context has been discarded Failed to decode response from marionette

Any idea what could have caused this outside the code? (since no changes were made)

I'm using firefox and geckodriver. After i got these errors i updated firefox, geckodriver, and selenium, but it didn't help.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Tintinabulator Zea
  • 2,617
  • 5
  • 18
  • 32

4 Answers4

6

This error message...

Browsing context has been discarded
.
Failed to decode response from marionette

...implies that the communication between GeckoDriver and Marionette was broken.

Some more information regarding the binary version interms of:

  • Selenium Server/Client
  • GeckoDriver
  • Firefox

Additionally, your code block and the error stack trace would have given us some clues about whats wrong happening. However this issue can happen due to multiple factors as follows:

GeckoDriver, Selenium and Firefox Browser compatibility chart

GeckoDriverVersions


Reference

You can find a relevant detailed discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Can I find this compatibility table somewhere? – Čamo Feb 11 '20 at 18:22
  • [@Čamo](https://stackoverflow.com/users/2092927/%c4%8camo) *GeckoDriver, Selenium and Firefox Browser compatibility chart* is clickable and redirects to https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html – Benjamin Loison May 07 '23 at 11:57
1

I experienced the same error on a particular site, after performing a successful login and when I was redirected to the next page.

While Inspecting the source of the new page code in my Firefox browser, I noticed some bad format/HTML quality details that went away after a manual refresh. (I suspect related to lack of quality of that site in particular).

What I did in order to remediate this was to start every next step on a new page with a refresh on my driver:

def my_next_step(driver):
    driver.refresh()
    time.sleep(10)
    element=driver.switch_to_frame('iframe')
    # .......

This helped me overcome the site quality issues.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
1

On Ubuntu 22.10 using (apt, not snap) Firefox and Selenium in Python I also got this error after:

driver.switch_to.alert.accept()

The solution for me was to switch back to the context with:

def upload_file(driver, filepath):
    """Uploads a Ublock Origin backup (template) .txt file into the Ublock
    Origin extension."""
    driver.find_element("id", "restoreFilePicker").send_keys(filepath)
    time.sleep(1)
    driver.switch_to.alert.accept()
    time.sleep(1)
    # Switch back to first tab (and reload/restore it).
    new_window = driver.window_handles[0]
    driver.switch_to.window(new_window)

This answer was given in this question.

a.t.
  • 2,002
  • 3
  • 26
  • 66
0

I removed size of window it is working without this error

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 04 '22 at 18:52