def _proxy(self): logger.info("proxy: {}".format(self.proxy)) if self.proxy and isinstance(self.proxy, dict) and self.browser == 'chrome': proxy = Proxy() for k, v in self.proxy.items(): proxy.__setattr__(k, v) capabilities = webdriver.DesiredCapabilities.CHROME proxy.add_to_capabilities(capabilities) return capabilities elif self.proxy and isinstance(self.proxy, dict) and self.browser == 'firefox': profile = FirefoxProfile() profile.set_preference('network.proxy.type', 1) for k, v in self.proxy.items(): scheme = k.split("_") host_details = v.split(":") if len(scheme) > 1 and len(host_details) > 1: profile.set_preference("network.proxy.%s" % scheme[0], host_details[0]) profile.set_preference("network.proxy.%s_port" % scheme[0], int(host_details[1])) profile.update_preferences() # profile.accept_untrusted_certs = True return profile