简体   繁体   中英

Webdriver connected to selenium-server:4444 a through proxy

When I run (WinXP OS, Python 2.7)

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

in my system there is a proxy server by default, and is connected to selenium-server:4444 a through proxy. How to make that connection went directly to selenium-server:4444.

It is a bit late, but I stumbled over the same problem today and solved it, so for the next one who searches, here is the solution:

The system proxy settings are fetched from the *_proxy windows environment variables (http_proxy, https_proxy, ftp_proxy, ...), so if you have a company proxy defined there it will be used.

Add a new environment variable in windows options or, if you use intelliJ IDEA, in the Run configuration settings:

no_proxy=localhost,127.0.0.1

The reason you will find in python-2.7.6/Lib/urllib.py, around line 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM