|
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 | +import typing |
17 | 18 |
|
18 | 19 | from selenium.webdriver.common import service
|
19 | 20 |
|
20 | 21 | DEFAULT_EXECUTABLE_PATH = "WPEWebDriver"
|
21 | 22 |
|
22 | 23 |
|
23 | 24 | class Service(service.Service):
|
24 |
| - """ |
25 |
| - Object that manages the starting and stopping of the WPEWebKitDriver |
26 |
| - """ |
| 25 | + """A Service class that is responsible for the starting and stopping |
| 26 | + of `WPEWebDriver`. |
27 | 27 |
|
28 |
| - def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH, port=0, log_path=None): |
29 |
| - """ |
30 |
| - Creates a new instance of the Service |
| 28 | + :param executable_path: install path of the WPEWebDriver executable, defaults to `WPEWebDriver`. |
| 29 | + :param port: Port for the service to run on, defaults to 0 where the operating system will decide. |
| 30 | + :param service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable. |
| 31 | + :param log_path: (Optional) String to be passed to the executable as `--log-path`. |
| 32 | + :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. |
| 33 | + """ |
31 | 34 |
|
32 |
| - :Args: |
33 |
| - - executable_path : Path to the WPEWebKitDriver |
34 |
| - - port : Port the service is running on |
35 |
| - - log_path : Path for the WPEWebKitDriver service to log to |
36 |
| - """ |
| 35 | + def __init__( |
| 36 | + self, |
| 37 | + executable_path: str = DEFAULT_EXECUTABLE_PATH, |
| 38 | + port: int = 0, |
| 39 | + log_path: typing.Optional[str] = None, |
| 40 | + service_args: typing.Optional[typing.Sequence[str]] = None, |
| 41 | + env: typing.Optional[typing.Mapping[str, str]] = None, |
| 42 | + ): |
| 43 | + self.service_args = service_args or [] |
37 | 44 | log_file = open(log_path, "wb") if log_path else None
|
38 |
| - super().__init__(executable_path, port, log_file) |
| 45 | + super().__init__(executable=executable_path, port=port, log_file=log_file, env=env) |
39 | 46 |
|
40 |
| - def command_line_args(self): |
41 |
| - return ["-p", f"{self.port}"] |
| 47 | + def command_line_args(self) -> typing.List[str]: |
| 48 | + return ["-p", f"{self.port}"] + self.service_args |
0 commit comments