Skip to content

Commit f1a7bf6

Browse files
jerry-gitlmtierney
authored andcommitted
[py] Be consistent with webdriver init kwarg service_log_path (#5979)
Deprecate log_file for IE and log_path for Edge and Firefox. Fixes #5725
1 parent b6f307c commit f1a7bf6

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

py/selenium/webdriver/edge/webdriver.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
import warnings
1718

1819
from selenium.webdriver.common import utils
1920
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
@@ -25,12 +26,16 @@
2526
class WebDriver(RemoteWebDriver):
2627

2728
def __init__(self, executable_path='MicrosoftWebDriver.exe',
28-
capabilities=None, port=0, verbose=False, log_path=None):
29+
capabilities=None, port=0, verbose=False, service_log_path=None, log_path=None):
30+
if log_path:
31+
warnings.warn('use service_log_path instead of log_path', DeprecationWarning)
32+
service_log_path = log_path
33+
2934
self.port = port
3035
if self.port == 0:
3136
self.port = utils.free_port()
3237

33-
self.edge_service = Service(executable_path, port=self.port, verbose=verbose, log_path=log_path)
38+
self.edge_service = Service(executable_path, port=self.port, verbose=verbose, log_path=service_log_path)
3439
self.edge_service.start()
3540

3641
if capabilities is None:

py/selenium/webdriver/firefox/webdriver.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class WebDriver(RemoteWebDriver):
5656
def __init__(self, firefox_profile=None, firefox_binary=None,
5757
timeout=30, capabilities=None, proxy=None,
5858
executable_path="geckodriver", options=None,
59-
log_path="geckodriver.log", firefox_options=None,
60-
service_args=None, desired_capabilities=None):
59+
service_log_path="geckodriver.log", firefox_options=None,
60+
service_args=None, desired_capabilities=None, log_path=None):
6161
"""Starts a new local session of Firefox.
6262
6363
Based on the combination and specificity of the various keyword
@@ -100,12 +100,15 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
100100
binary to use for Firefox 47.0.1 and greater, which
101101
defaults to picking up the binary from the system path.
102102
:param options: Instance of ``options.Options``.
103-
:param log_path: Where to log information from the driver.
103+
:param service_log_path: Where to log information from the driver.
104104
:param desired_capabilities: alias of capabilities. In future
105105
versions of this library, this will replace 'capabilities'.
106106
This will make the signature consistent with RemoteWebDriver.
107107
108108
"""
109+
if log_path:
110+
warnings.warn('use service_log_path instead of log_path', DeprecationWarning)
111+
service_log_path = log_path
109112
if firefox_options:
110113
warnings.warn('use options instead of firefox_options', DeprecationWarning)
111114
options = firefox_options
@@ -156,7 +159,7 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
156159
self.service = Service(
157160
executable_path,
158161
service_args=service_args,
159-
log_path=log_path)
162+
log_path=service_log_path)
160163
self.service.start()
161164

162165
capabilities.update(options.to_capabilities())

py/selenium/webdriver/ie/webdriver.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
DEFAULT_PORT = 0
2626
DEFAULT_HOST = None
2727
DEFAULT_LOG_LEVEL = None
28-
DEFAULT_LOG_FILE = None
28+
DEFAULT_SERVICE_LOG_PATH = None
2929

3030

3131
class WebDriver(RemoteWebDriver):
3232
""" Controls the IEServerDriver and allows you to drive Internet Explorer """
3333

3434
def __init__(self, executable_path='IEDriverServer.exe', capabilities=None,
3535
port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST,
36-
log_level=DEFAULT_LOG_LEVEL, log_file=DEFAULT_LOG_FILE, options=None,
37-
ie_options=None, desired_capabilities=None):
36+
log_level=DEFAULT_LOG_LEVEL, service_log_path=DEFAULT_SERVICE_LOG_PATH, options=None,
37+
ie_options=None, desired_capabilities=None, log_file=None):
3838
"""
3939
Creates a new instance of the chrome driver.
4040
@@ -45,19 +45,20 @@ def __init__(self, executable_path='IEDriverServer.exe', capabilities=None,
4545
- capabilities: capabilities Dictionary object
4646
- port - port you would like the service to run, if left as 0, a free port will be found.
4747
- log_level - log level you would like the service to run.
48-
- log_file - log file you would like the service to log to.
48+
- service_log_path - target of logging of service, may be "stdout", "stderr" or file path.
4949
- options: IE Options instance, providing additional IE options
5050
- desired_capabilities: alias of capabilities; this will make the signature consistent with RemoteWebDriver.
5151
"""
52+
if log_file:
53+
warnings.warn('use service_log_path instead of log_file', DeprecationWarning)
54+
service_log_path = log_file
5255
if ie_options:
5356
warnings.warn('use options instead of ie_options', DeprecationWarning)
5457
options = ie_options
5558
self.port = port
5659
if self.port == 0:
5760
self.port = utils.free_port()
5861
self.host = host
59-
self.log_level = log_level
60-
self.log_file = log_file
6162

6263
# If both capabilities and desired capabilities are set, ignore desired capabilities.
6364
if capabilities is None and desired_capabilities:
@@ -77,8 +78,8 @@ def __init__(self, executable_path='IEDriverServer.exe', capabilities=None,
7778
executable_path,
7879
port=self.port,
7980
host=self.host,
80-
log_level=self.log_level,
81-
log_file=self.log_file)
81+
log_level=log_level,
82+
log_file=service_log_path)
8283

8384
self.iedriver.start()
8485

py/test/selenium/webdriver/firefox/ff_launcher_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ def test_we_can_launch_multiple_firefox_instances(capabilities):
2727
driver3.quit()
2828

2929

30-
def test_launch_firefox_with_none_log_path(capabilities):
31-
driver = Firefox(capabilities=capabilities, log_path=None)
30+
def test_launch_firefox_with_none_service_log_path(capabilities):
31+
driver = Firefox(capabilities=capabilities, service_log_path=None)
3232
driver.quit()
3333

3434

35-
def test_launch_firefox_with_empty_string_log_path(capabilities):
36-
driver = Firefox(capabilities=capabilities, log_path="")
35+
def test_launch_firefox_with_empty_string_service_log_path(capabilities):
36+
driver = Firefox(capabilities=capabilities, service_log_path="")
3737
driver.quit()

py/test/selenium/webdriver/marionette/mn_launcher_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ def test_we_can_launch_multiple_firefox_instances(capabilities):
3131
driver3.quit()
3232

3333

34-
def test_launch_firefox_with_none_log_path(capabilities):
35-
driver = Firefox(capabilities=capabilities, log_path=None)
34+
def test_launch_firefox_with_none_service_log_path(capabilities):
35+
driver = Firefox(capabilities=capabilities, service_log_path=None)
3636
driver.quit()
3737

3838

39-
def test_launch_firefox_with_empty_string_log_path(capabilities):
40-
driver = Firefox(capabilities=capabilities, log_path="")
39+
def test_launch_firefox_with_empty_string_service_log_path(capabilities):
40+
driver = Firefox(capabilities=capabilities, service_log_path="")
4141
driver.quit()

0 commit comments

Comments
 (0)