@@ -325,3 +325,39 @@ def to_capabilities(self):
325325 if attr_value :
326326 proxy_caps [proxy ] = attr_value
327327 return proxy_caps
328+
329+ def to_bidi_dict (self ):
330+ """Convert proxy settings to BiDi format.
331+
332+ Returns:
333+ -------
334+ dict: Proxy configuration in BiDi format.
335+ """
336+ proxy_type = self .proxyType ["string" ].lower ()
337+ result = {"proxyType" : proxy_type }
338+
339+ if proxy_type == "manual" :
340+ if self .httpProxy :
341+ result ["httpProxy" ] = self .httpProxy
342+ if self .sslProxy :
343+ result ["sslProxy" ] = self .sslProxy
344+ if self .socksProxy :
345+ result ["socksProxy" ] = self .socksProxy
346+ if self .socksVersion is not None :
347+ result ["socksVersion" ] = self .socksVersion
348+ if self .noProxy :
349+ # Convert comma-separated string to list
350+ if isinstance (self .noProxy , str ):
351+ result ["noProxy" ] = [host .strip () for host in self .noProxy .split ("," ) if host .strip ()]
352+ elif isinstance (self .noProxy , list ):
353+ if not all (isinstance (h , str ) for h in self .noProxy ):
354+ raise TypeError ("no_proxy list must contain only strings" )
355+ result ["noProxy" ] = self .noProxy
356+ else :
357+ raise TypeError ("no_proxy must be a comma-separated string or a list of strings" )
358+
359+ elif proxy_type == "pac" :
360+ if self .proxyAutoconfigUrl :
361+ result ["proxyAutoconfigUrl" ] = self .proxyAutoconfigUrl
362+
363+ return result
0 commit comments