'selenium.common.exceptions.WebDriverException: Message: target frame detached

every now and then this error appears when I launch my script. It doesn't happen all the time, I often only need to run the script again to not get this message anymore. What could be the problem?

Traceback (most recent call last):
  File "C:\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 927, in page_source
    return self.execute(Command.GET_PAGE_SOURCE)['value']
  File "C:\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 425, in execute
    self.error_handler.check_response(response)
  File "C:\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: target frame detached
  (Session info: chrome=100.0.4896.127)
Stacktrace:
Backtrace:
    Ordinal0 [0x00EC9943+2595139]
    Ordinal0 [0x00E5C9F1+2148849]
    Ordinal0 [0x00D543F0+1065968]
    Ordinal0 [0x00D45A97+1006231]
    Ordinal0 [0x00D44AD0+1002192]
    Ordinal0 [0x00D450D8+1003736]
    Ordinal0 [0x00D45068+1003624]
    Ordinal0 [0x00D4B220+1028640]
    Ordinal0 [0x00D462AD+1008301]
    Ordinal0 [0x00D467C5+1009605]
    Ordinal0 [0x00D465AF+1009071]
    Ordinal0 [0x00D45BC6+1006534]
    Ordinal0 [0x00D4542B+1004587]
    Ordinal0 [0x00D452C9+1004233]
    Ordinal0 [0x00D558A0+1071264]
    Ordinal0 [0x00DAB3BB+1422267]
    Ordinal0 [0x00D9B806+1357830]
    Ordinal0 [0x00D76086+1204358]
    Ordinal0 [0x00D76F96+1208214]
    GetHandleVerifier [0x0106B232+1658114]
    GetHandleVerifier [0x0112312C+2411516]
    GetHandleVerifier [0x00F5F261+560433]
    GetHandleVerifier [0x00F5E366+556598]
    Ordinal0 [0x00E6286B+2173035]
    Ordinal0 [0x00E675F8+2192888]
    Ordinal0 [0x00E676E5+2193125]
    Ordinal0 [0x00E711FC+2232828]
    BaseThreadInitThunk [0x76A1FA29+25]
    RtlGetAppContainerNamedObjectPath [0x77007A7E+286]
    RtlGetAppContainerNamedObjectPath [0x77007A4E+238]


Solution 1:[1]

Try to check that:

  • Selenium is upgraded to the latest available version
  • ChromeDriver and Chrome Browser are updated to the latest available version
  • Or, if you use Firefox, check that GeckoDriver and Firefox Browser are updated to the latest available version

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 WillyWhite