Skip to content

Commit d20db99

Browse files
committed
[py]: docs and types for EdgeService. deprecate verbose=True
1 parent 7c7e2ec commit d20db99

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

py/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,9 @@ def webserver():
241241
webserver.start()
242242
yield webserver
243243
webserver.stop()
244+
245+
246+
@pytest.fixture
247+
def edge_service():
248+
from selenium.webdriver.edge.service import Service as EdgeService
249+
return EdgeService

py/selenium/webdriver/chromium/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ChromiumService(service.Service):
2626
:param executable_path: install path of the executable.
2727
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
2828
:param service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.
29-
:param log_path: (Optional) String to be passed to the executable as `--log-path`
29+
:param log_path: (Optional) String to be passed to the executable as `--log-path`.
3030
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
3131
:param start_error_message: (Optional) Error message that forms part of the error when problems occur
3232
launching the subprocess.

py/selenium/webdriver/edge/service.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,51 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
18-
from typing import List
17+
import typing
18+
import warnings
1919

2020
from selenium.webdriver.chromium import service
2121

2222
DEFAULT_EXECUTABLE_PATH = "msedgedriver"
2323

2424

2525
class Service(service.ChromiumService):
26+
"""A Service class that is responsible for the starting and stopping
27+
of `msedgedriver`.
28+
29+
:param executable_path: install path of the msedgedriver executable, defaults to `msedgedriver`.
30+
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
31+
:param verbose: (Deprecated) Whether to make the webdriver more verbose (passes the --verbose option to the binary).
32+
Defaults to False.
33+
:param log_path: (Optional) String to be passed to the executable as `--log-path`.
34+
:param service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.
35+
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
36+
"""
37+
2638
def __init__(
2739
self,
2840
executable_path: str = DEFAULT_EXECUTABLE_PATH,
2941
port: int = 0,
3042
verbose: bool = False,
31-
log_path: str = None,
32-
service_args: List[str] = None,
33-
env=None,
43+
log_path: typing.Optional[str] = None,
44+
service_args: typing.Optional[typing.Sequence[str]] = None,
45+
env: typing.Optional[typing.Mapping[str, str]] = None,
3446
):
35-
"""
36-
Creates a new instance of the EdgeDriver service.
37-
EdgeDriver provides an interface for Microsoft WebDriver to use
38-
with Microsoft Edge.
39-
40-
:Args:
41-
- executable_path : Path to the Microsoft WebDriver binary.
42-
- port : Run the remote service on a specified port. Defaults to 0, which binds to a random open port
43-
of the system's choosing.
44-
- verbose : Whether to make the webdriver more verbose (passes the --verbose option to the binary).
45-
Defaults to False.
46-
- log_path : Optional path for the webdriver binary to log to. Defaults to None which disables logging.
47-
- service_args : List of args to pass to the WebDriver service.
48-
"""
4947
self.service_args = service_args or []
5048

5149
if verbose:
50+
warnings.warn(
51+
"verbose=True is deprecated. Use `service_args=['--verbose', ...]` instead.",
52+
DeprecationWarning,
53+
stacklevel=2,
54+
)
5255
self.service_args.append("--verbose")
5356

5457
super().__init__(
55-
executable_path,
56-
port,
57-
service_args,
58-
log_path,
59-
env,
60-
"Please download from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/",
58+
executable_path=executable_path,
59+
port=port,
60+
service_args=service_args,
61+
log_path=log_path,
62+
env=env,
63+
start_error_message="Please download from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/",
6164
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
4+
def test_edge_service_verbose_flag_is_deprecated(edge_service) -> None:
5+
with pytest.warns(match="verbose=True is deprecated", expected_warning=DeprecationWarning):
6+
edge_service(verbose=True)

0 commit comments

Comments
 (0)