|
14 | 14 | # KIND, either express or implied. See the License for the
|
15 | 15 | # specific language governing permissions and limitations
|
16 | 16 | # under the License.
|
17 |
| - |
18 |
| -from typing import List |
| 17 | +import typing |
| 18 | +import warnings |
19 | 19 |
|
20 | 20 | from selenium.webdriver.chromium import service
|
21 | 21 |
|
22 | 22 | DEFAULT_EXECUTABLE_PATH = "msedgedriver"
|
23 | 23 |
|
24 | 24 |
|
25 | 25 | 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 | + |
26 | 38 | def __init__(
|
27 | 39 | self,
|
28 | 40 | executable_path: str = DEFAULT_EXECUTABLE_PATH,
|
29 | 41 | port: int = 0,
|
30 | 42 | 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, |
34 | 46 | ):
|
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 |
| - """ |
49 | 47 | self.service_args = service_args or []
|
50 | 48 |
|
51 | 49 | if verbose:
|
| 50 | + warnings.warn( |
| 51 | + "verbose=True is deprecated. Use `service_args=['--verbose', ...]` instead.", |
| 52 | + DeprecationWarning, |
| 53 | + stacklevel=2, |
| 54 | + ) |
52 | 55 | self.service_args.append("--verbose")
|
53 | 56 |
|
54 | 57 | 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/", |
61 | 64 | )
|
0 commit comments