Selenium Chromedriver Python - 'failed to wait for extension background page to load' when loading ModHeader extension using Tor proxy

Viewed 4692

This bug occurred out of nowhere in a program that previously functioned perfectly. I'm absolutely certain I have not done any changes on the program since it's functionality was perfect, so this is by far the weirdest and most frustrating bug I have ever experienced.

This is the code I'm trying to execute:

chrome_options.add_extension('C:\\chromedriver\\ModHeader_v (1).crx')
chrome_options.add_argument('--proxy-server=socks5://' + '127.0.0.1:9150') 
driver = webdriver.Chrome('C:\\chromedriver\\chromedriver.exe', chrome_options = chrome_options)

Which raises the following error:

selenium.common.exceptions.WebDriverException: Message: unknown error: failed to wait for extension background page to load: chrome-extension://idgpnmonknjnojddfkpgkljpfnnfcklj/_generated_background_page.html from timeout: Timed out receiving message from renderer: 10.000
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 10.0.15063 x86_64)

I assume that a change within the Tor browser is causing this bug. There is no other potential cause.

2 Answers

Try to use Seleniumwire, for example:

from seleniumwire import webdriver

def set_chrome_driver():
        options = webdriver.ChromeOptions()
        options.add_argument("--start-maximized")
        options.add_argument("--disable-infobars")
        options.add_argument("--no-proxy-server")
        driver = webdriver.Chrome(executable_path=r'C:\Automation_package\chromedriver.exe')
        driver.get('http://172.1.1.1:5000/path/api/')
        driver.header_overrides = {"iv-user": "Admin", "iv-groups": "SuperAdmin", "iv-roles": "Viewers",}
        driver.get('http://172.1.1.1:5000/path/api/')
Related