wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.9k stars 254 forks source link

Headless not working. #495

Closed tomekozlowski closed 2 years ago

tomekozlowski commented 2 years ago
                options = {
                    'headless': True,
                   'proxy': {
                        'http': f'socks5://{pass1}:{pass2}@{key}:{value}',
                        'https': f'socks5://{pass1}:{pass2}@{key}:{value}',
                        'no_proxy': 'localhost,127.0.0.1',
                    },
                    'detach': True,
                    'window-size': '1920x1080',
                    'prefs': {
                        'headless': True,
                        'credentials_enable_service': False,
                        'profile': {
                            'headless': True
                            'password_manager_enabled': False,
                            'default_content_setting_values.notifications': 2,
                }}}
                driver = webdriver.Chrome(seleniumwire_options=options)

I've tried adding it everywhere, to no avail, any solutions?

wkeeling commented 2 years ago

Thanks for raising this.

The headless option is a Chrome option not a Selenium Wire option - so you need to pass it via that route, e.g.

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')

driver = webdriver.Chrome(
    options=chrome_options,
    seleniumwire_options=options
)

Many of the other options that you are passing (e.g. window size, detach, prefs) are also Chrome options and not Selenium Wire options so should be passed via the same route.

Some examples are here, here and a comprehensive list of all Chrome options here. You can find the Selenium Wire specific options here.

tomekozlowski commented 2 years ago

Thanks, ur a chad, I didn't know I could split and import my normal selenium options, alongside with seleniumwires' by using this. driver = webdriver.Chrome(options=chrome_options, seleniumwire_options=options) This solved the issue. Big thanks!