diff --git a/py/selenium/webdriver/ie/webdriver.py b/py/selenium/webdriver/ie/webdriver.py index 1228567350895..76190ca2f9381 100644 --- a/py/selenium/webdriver/ie/webdriver.py +++ b/py/selenium/webdriver/ie/webdriver.py @@ -20,6 +20,7 @@ from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver from .service import Service from .options import Options +from selenium.webdriver.common import utils DEFAULT_TIMEOUT = 30 DEFAULT_PORT = 0 @@ -62,7 +63,6 @@ def __init__(self, executable_path='IEDriverServer.exe', capabilities=None, if port != DEFAULT_PORT: warnings.warn('port has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) - self.port = port if timeout != DEFAULT_TIMEOUT: warnings.warn('timeout has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) @@ -76,6 +76,9 @@ def __init__(self, executable_path='IEDriverServer.exe', capabilities=None, if service_log_path != DEFAULT_SERVICE_LOG_PATH: warnings.warn('service_log_path has been deprecated, please pass in a Service object', DeprecationWarning, stacklevel=2) + self.port = port + if self.port == 0: + self.port = utils.free_port() # If both capabilities and desired capabilities are set, ignore desired capabilities. if capabilities is None and desired_capabilities: