Skip to content

Commit 4a759a8

Browse files
committed
[py]: Types and docs for wpiwebkit.service and additional args for consistency
1 parent 3e41af7 commit 4a759a8

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

py/selenium/webdriver/webkitgtk/service.py

Lines changed: 2 additions & 1 deletion
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 typing
1718

1819
from selenium.webdriver.common import service
1920

@@ -37,5 +38,5 @@ def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH, port=0, log_p
3738
log_file = open(log_path, "wb") if log_path else None
3839
super().__init__(executable_path, port, log_file)
3940

40-
def command_line_args(self):
41+
def command_line_args(self) -> typing.List[str]:
4142
return ["-p", f"{self.port}"]

py/selenium/webdriver/wpewebkit/service.py

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

1819
from selenium.webdriver.common import service
1920

2021
DEFAULT_EXECUTABLE_PATH = "WPEWebDriver"
2122

2223

2324
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`.
2727
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+
"""
3134

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 []
3744
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)
3946

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

Comments
 (0)