wkeeling / selenium-wire

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

tls.VERSION_CHOICES issue #659

Open Kamran-ov opened 1 year ago

Kamran-ov commented 1 year ago

Hi Today, I needed to download mitmproxy for some project and I did it by mistake in the general python environment. So, I did pip install mitmproxy.

However, after this my seleniumwire started giving tls.VERSION_CHOICES error. I have uninstalled mitmproxy package and folders and uninstalled/reinstalled seleniumwire, However, nothing helps me. Cna you please help me to fix this issue? I just simply try to create a driver with the below code. from seleniumwire.undetected_chromedriver.v2 import Chrome, ChromeOptions driver = Chrome()

The error Message:

AttributeError Traceback (most recent call last) Input In [76], in <cell line: 2>() 1 from seleniumwire.undetected_chromedriver.v2 import Chrome, ChromeOptions ----> 2 driver = Chrome()

File ~\anaconda3\lib\site-packages\seleniumwire\undetected_chromedriver\webdriver.py:32, in Chrome.init(self, seleniumwire_options, *args, **kwargs) 29 if seleniumwire_options is None: 30 seleniumwire_options = {} ---> 32 config = self._setup_backend(seleniumwire_options) 34 if seleniumwire_options.get('auto_config', True): 35 capabilities = kwargs.get('desired_capabilities')

File ~\anaconda3\lib\site-packages\seleniumwire\webdriver.py:41, in DriverCommonMixin._setup_backend(self, seleniumwire_options) 37 def _setup_backend(self, seleniumwire_options: Dict[str, Any]) -> Dict[str, Any]: 38 """Create the backend proxy server and return its configuration 39 in a dictionary. 40 """ ---> 41 self.backend = backend.create( 42 addr=seleniumwire_options.pop('addr', '127.0.0.1'), 43 port=seleniumwire_options.get('port', 0), 44 options=seleniumwire_options, 45 ) 47 addr, port = utils.urlsafe_address(self.backend.address()) 49 config = { 50 'proxy': { 51 'proxyType': 'manual', (...) 54 } 55 }

File ~\anaconda3\lib\site-packages\seleniumwire\backend.py:24, in create(addr, port, options) 21 if options is None: 22 options = {} ---> 24 backend = MitmProxy(addr, port, options) 26 t = threading.Thread(name='Selenium Wire Proxy Server', target=backend.serve_forever) 27 t.daemon = not options.get('standalone')

File ~\anaconda3\lib\site-packages\seleniumwire\server.py:42, in MitmProxy.init(self, host, port, options) 38 self.response_interceptor = None 40 self._event_loop = asyncio.new_event_loop() ---> 42 mitmproxy_opts = Options() 44 self.master = Master(self._event_loop, mitmproxy_opts) 45 self.master.addons.add(*addons.default_addons())

File ~\anaconda3\lib\site-packages\seleniumwire\thirdparty\mitmproxy\options.py:149, in Options.init(self, **kwargs) 129 self.add_option( 130 "rawtcp", bool, False, 131 "Enable/disable experimental raw TCP support. TCP connections starting with non-ascii " 132 "bytes are treated as if they would match tcp_hosts. The heuristic is very rough, use " 133 "with caution. Disabled by default. " 134 ) 136 self.add_option( 137 "spoof_source_address", bool, False, 138 """ (...) 141 """ 142 ) 143 self.add_option( 144 "ssl_version_client", str, "secure", 145 """ 146 Set supported SSL/TLS versions for client connections. SSLv2, SSLv3 147 and 'all' are INSECURE. Defaults to secure, which is TLS1.0+. 148 """, --> 149 choices=list(tls.VERSION_CHOICES.keys()), 150 ) 151 self.add_option( 152 "ssl_version_server", str, "secure", 153 """ (...) 157 choices=list(tls.VERSION_CHOICES.keys()), 158 ) 159 self.add_option( 160 "ssl_insecure", bool, False, 161 "Do not verify upstream server SSL/TLS certificates." 162 )

AttributeError: module 'seleniumwire.thirdparty.mitmproxy.net.tls' has no attribute 'VERSION_CHOICES'