Reputation: 2807
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.
Upvotes: 12
Views: 23720
Reputation: 11
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.
Upvotes: 1
Reputation: 2798
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.
Upvotes: 4
Reputation: 193078
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:
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:
driver.navigate().back();
when Selenium's focus was within an <iframe>
this error is observed.You can find a relevant detailed discussion in:
Upvotes: 6