2012-09-28 136 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