Skip to content

Commit d4af5ec

Browse files
committed
Edge requires 'localhost' for the http request, resolving IP address and using it as the url is forbidden
Fixes #1015
1 parent 4d6d037 commit d4af5ec

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

py/selenium/webdriver/edge/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def start(self):
5959
"The EdgeDriver executable needs to be available in the path. "
6060
"Please download from http://go.microsoft.com/fwlink/?LinkId=619687 ")
6161
count = 0
62-
while not utils.is_url_connectable(self.port):
62+
while not utils.is_connectable(self.port):
6363
count += 1
6464
time.sleep(1)
6565
if count == 30:

py/selenium/webdriver/edge/webdriver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from selenium.webdriver.common import utils
1919
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
20+
from selenium.webdriver.remote.remote_connection import RemoteConnection
2021
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
2122
from .service import Service
2223

@@ -37,7 +38,8 @@ def __init__(self, executable_path='MicrosoftWebDriver.exe',
3738

3839
RemoteWebDriver.__init__(
3940
self,
40-
command_executor='http://localhost:%d' % self.port,
41+
command_executor=RemoteConnection('http://localhost:%d' % self.port,
42+
resolve_ip=False),
4143
desired_capabilities=capabilities)
4244
self._is_remote = False
4345

py/selenium/webdriver/remote/remote_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ def reset_timeout(cls):
161161
"""
162162
cls._timeout = socket._GLOBAL_DEFAULT_TIMEOUT
163163

164-
def __init__(self, remote_server_addr, keep_alive=False):
164+
def __init__(self, remote_server_addr, keep_alive=False, resolve_ip=True):
165165
# Attempt to resolve the hostname and get an IP address.
166166
self.keep_alive = keep_alive
167167
parsed_url = parse.urlparse(remote_server_addr)
168168
self._hostname = parsed_url.hostname
169169
addr = ""
170-
if parsed_url.hostname:
170+
if parsed_url.hostname and resolve_ip:
171171
try:
172172
netloc = socket.gethostbyname(parsed_url.hostname)
173173
addr = netloc

0 commit comments

Comments
 (0)