2012-09-28 138 views
1

当我运行(操作系统OS,Python 2.7版)的webdriver连接到硒服务器:4444一通过代理

wd = webdriver.Remote (command_executor = 'http://127.0.0.1:4444/hub', desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER) 
在我的系统

有默认代理服务器,并连接到硒服务器: 4444通过代理。如何使该连接直接进入selenium-server:4444。

回答

0

这是一个有点晚了,但我今天碰上了同样的问题,解决了这个问题,所以下一个谁搜索,这里是解决方案:

系统代理设置是从* _proxy窗口取环境变量(http_proxy,https_proxy,ftp_proxy,...),所以如果你有一个在那里定义的公司代理,它将被使用。

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

no_proxy=localhost,127.0.0.1 

你会找到原因的python-2.7.6 /库/ 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