0

I'm trying to perform a fairly simple action using Selenium, namely opening google images in Firefox browser. I also use a proxy server running on the localhost.

from selenium.webdriver import Firefox, FirefoxOptions
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.common.proxy import Proxy, ProxyType

options = FirefoxOptions()
service = Service()
options.add_argument("--headless")
options.accept_insecure_certs = True 

proxy = Proxy({
    'httpProxy': proxy_addr,
    'sslProxy': proxy_addr,
    'proxyType': ProxyType.MANUAL
})

options.proxy = proxy

b = Firefox(service=service, options=options)
b.execute("get", {'url': 'http://images.google.com'})

But unfortunately, I'm getting an error like this:

selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=contentEncodingError&u=https%3A//images.google.com/%3Fgws_rd%3Dssl&c=UTF-8&d=The%20page%20you%20are%20trying%20to%20view%20cannot%20be%20shown%20because%20it%20uses%20an%20invalid%20or%20unsupported%20form%20of%20compression.

I would be very grateful for any thoughts and advice what exactly might be the problem and at least approximately what should be paid attention to.

I'm using:

debian
firefox-esr
selenium == 4.2.0
geckodriver-v0.31.0
Helen
  • 463
  • 2
  • 9
  • 23

1 Answers1

1

This error message...

selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=contentEncodingError&u=https%3A//images.google.com/%3Fgws_rd%3Dssl&c=UTF-8&d=The%20page%20you%20are%20trying%20to%20view%20cannot%20be%20shown%20because%20it%20uses%20an%20invalid%20or%20unsupported%20form%20of%20compression.

...implies that there are some configuration settings mismatch while GeckoDriver initiates/spawns a new Browsing Context i.e. session and is often observed as:

Content Encoding Error


Solution

As per the mozilla support docs you need to try out the following steps:

  • Try to reset the network.http.accept-encoding prefs on the about:config page in case they show as user set (bold). You can open the about:config page via the location/address bar. You can accept the warning and click "I'll be careful" to continue.
  • If you are having Avast Antivirus or Malwarebytes installed, you may need to disable those in the test machine before executing the tests.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thank you very much for the answer! But I don't really understand how can I reset the `network.http.accept-encoding` prefs through `Selenium`. And I don't use neither Avast Antivirus nor Malwarebytes. – Helen Jul 20 '22 at 06:12
  • I'm asking this because I need to run certain tests in docker so I won't be able to manually change `network.http.accept-encoding` prefs each time. – Helen Jul 20 '22 at 06:16
  • 1
    Reset `network.http.accept-encoding` manually, you may like to restart the test system as well. – undetected Selenium Jul 20 '22 at 06:50
  • I'm sorry, but I still don't understand. How to do it if I use headless browser without a graphical UI? – Helen Jul 20 '22 at 06:53
  • 1
    Ahh, first things first please remove `options.set_capability('marionette', False)`. Using **marionette** is mandatory. – undetected Selenium Jul 20 '22 at 07:03
  • Thanks for the advice! I removed this line, but unfortunately it did not help to solve the problem yet. – Helen Jul 20 '22 at 07:09
  • Can you reinstall the browser so the default settings are enforced. Haven't been able to reproduce the issue on ESR headless build. – undetected Selenium Jul 21 '22 at 16:05