【问题标题】:Webdriver connected to selenium-server:4444 a through proxyWebdriver 通过代理连接到 selenium-server:4444 a
【发布时间】:2012-09-20 03:06:24
【问题描述】:

当我运行时(WinXP OS,Python 2.7)

wd = webdriver.Remote (command_executor = 'http://127.0.0.1:4444/hub', desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER)

在我的系统中默认有一个代理服务器,并通过代理连接到 selenium-server:4444 a。如何使该连接直接转到 selenium-server:4444。

【问题讨论】:

    标签: python selenium python-2.7 webdriver


    【解决方案1】:

    有点晚了,但我今天偶然发现了同样的问题并解决了它,所以对于下一个搜索的人,这里是解决方案:

    系统代理设置是从 *_proxy windows 环境变量(http_proxy、https_proxy、ftp_proxy、...)中获取的,因此如果您在那里定义了公司代理,它将被使用。

    在 Windows 选项中添加一个新的环境变量,或者,如果您使用 IntelliJ IDEA,在运行配置设置中:

    no_proxy=localhost,127.0.0.1
    

    你会在 python-2.7.6/Lib/urllib.py 中找到原因,大约第 1387 行:

    def proxy_bypass_environment(host):
        """Test if proxies should not be used for a particular host.
    
        Checks the environment for a variable named no_proxy, which should
        be a list of DNS suffixes separated by commas, or '*' for all hosts.
        """
        no_proxy = os.environ.get('no_proxy', '') or os.environ.get('NO_PROXY', '')
        # '*' is special case for always bypass
        if no_proxy == '*':
            return 1
        # strip port off host
        hostonly, port = splitport(host)
        # check if the host ends with any of the DNS suffixes
        no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
        for name in no_proxy_list:
            if name and (hostonly.endswith(name) or host.endswith(name)):
                return 1
        # otherwise, don't bypass
        return 0
    

    【讨论】:

      猜你喜欢
      • 2020-02-12
      • 1970-01-01
      • 2011-01-04
      • 2023-03-16
      • 2023-03-16
      • 2012-01-07
      • 2015-07-10
      • 2014-07-17
      • 1970-01-01
      相关资源
      最近更新 更多