Skip to content

Commit

Permalink
[py]: docs and type hints for chrome.service
Browse files Browse the repository at this point in the history
  • Loading branch information
symonk committed Oct 4, 2022
1 parent 1fa4ca6 commit 3a788a3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
3 changes: 3 additions & 0 deletions py/selenium/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@

AnyKey = typing.Union[str, int, float]
WaitExcTypes = typing.Iterable[typing.Type[Exception]]

# Service Types
SubprocessStdAlias = typing.Union[int, typing.IO[typing.Any]]
37 changes: 19 additions & 18 deletions py/selenium/webdriver/chrome/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,37 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from typing import List
import typing

from selenium.webdriver.chromium import service

DEFAULT_EXECUTABLE_PATH = "chromedriver"


class Service(service.ChromiumService):
"""
Object that manages the starting and stopping of the ChromeDriver
"""A Service class that is responsible for the starting and stopping
of `chromedriver`.
:param executable_path: install path of the chromedriver executable, defaults to `chromedriver`.
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
:param service_args: (Optional) Sequence of args/flags to be passed to the `chromedriver` subprocess.
:param log_path: (Optional) String to be passed to the executable as `--log-path`
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
"""

def __init__(
self,
executable_path: str = DEFAULT_EXECUTABLE_PATH,
port: int = 0,
service_args: List[str] = None,
log_path: str = None,
env: dict = None,
):
"""
Creates a new instance of the Service
:Args:
- executable_path : Path to the ChromeDriver
- port : Port the service is running on
- service_args : List of args to pass to the chromedriver service
- log_path : Path for the chromedriver service to log to"""

service_args: typing.Optional[typing.Sequence[str]] = None,
log_path: typing.Optional[str] = None,
env: typing.Optional[typing.Mapping[str, str]] = None,
) -> None:
super().__init__(
executable_path, port, service_args, log_path, env, "Please see https://chromedriver.chromium.org/home"
executable_path=executable_path,
port=port,
service_args=service_args,
log_path=log_path,
env=env,
start_error_message="Please see https://chromedriver.chromium.org/home",
)
2 changes: 1 addition & 1 deletion py/selenium/webdriver/chromium/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
executable_path: str,
port: int = 0,
service_args: typing.Optional[List[str]] = None,
log_path: typing.Optional[typing.Union[str, int]] = None,
log_path: typing.Optional[str] = None,
env: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None,
start_error_message: str = "",
):
Expand Down

0 comments on commit 3a788a3

Please sign in to comment.