Skip to content Skip to sidebar Skip to footer

Conflicting Solutions For Different Errors With Python/selenium/chrome

I have been getting a series of pesky Selenium/Chrome errors for a week or so, where everything works fine for a while and then suddenly doesn't. I have the right version of Chrome

Solution 1:

Overview

  1. Prevalent issue - per @ss7777
  2. Albeit numerous potential causes for this/related

Blue-skies and 'silver-bullet' solution I'm afraid, however, here are some common causes and potential resolve / considerations etc.


Fixes/resolve

(accompanied by subj. view of 'commonality' | frequency)

  1. Driver: ChromeDriver version/file location (~50%) - incorrect version + ensure location to executable correct location

"This issue is pretty evident when there is a incompatibility between the version of the binaries you are using." (adapted from this source, with useful summary of historical versions v/ binaries)

  1. Chrome/driver still 'active' 5-20% - despite closing down, process tree elements can remain 'alive' or 'spinning' for some time - do you notice this right after restart of PC (here)?

(Have suffered and even evidenced this previously - e.g. running code in parallel, or simply executing through .bat at same time as PyCharm console).

  1. Updates: plugin/other incompatibly (~5-15%) - noting you're using headless - does it work with head?)
  2. System: clean up your system/restore-point or worst-face (~10-20%). (restore point worked for me)
  3. Other: spawn separate thread (~5% - see here)/alternative ports (as req/feasible)

Workarounds

  • Chrome dependency (e.g. see here - albeit potential red-herring..)
  • Mode of execution (through editor main program, through CMD interface hosted via editor (e.g. PyCharm console), or through .bat file (as mentioned previously), Standalone Selenium here
  • Configuration (technical/advanced - e.g. here)for advanced users)

Unresolved (albeit with promise)

Several cases of where such a Q remains unresolved/limited contribution:

(although 2nd point here points to remedy in item 2 above).


Extreme solns:

  • Have seen intense investigation and many too-fro re Q&A - with ultimate conclusion being complete reinstallation (Chrome/python, editor) etc.

Links / related

Solution 2:

I faced the same error once and I couldn't find a feasible solution anywhere. So I degraded my chrome version to v86.0 Even when you install the older version of chrome, you need to disable the chrome update to continue with your intended version. You can find the the steps here: https://www.webnots.com/7-ways-to-disable-automatic-chrome-update-in-windows-and-mac/ Along with the lower bowser version, I use the following code:

def test_setup(self):
    chrome_options=Options()
    chrome_options.add_argument('--start-maximized')
    chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
    chrome_options.add_argument("--remote-debugging-port=9222")
    chrome_options.add_argument('--no-sandbox')
    driver=webdriver.Chrome(executable_path="//your folder path//")

Try this once and let me know if it worked for you

Solution 3:

If you get this error. Try this way:

from webdriver_manager.chromeimportChromeDriverManager
options.add_argument("--restore-last-session")
options.add_argument("--disable-gaia-services")
driver = webdriver.Chrome(ChromeDriverManager().install(),options=options)

https://peter.sh/experiments/chromium-command-line-switches/

Post a Comment for "Conflicting Solutions For Different Errors With Python/selenium/chrome"