30
30
from urllib .error import URLError
31
31
32
32
from selenium .common .exceptions import WebDriverException
33
+ from selenium .types import SubprocessStdAlias
33
34
from selenium .webdriver .common import utils
34
35
35
36
log = logging .getLogger (__name__ )
39
40
40
41
41
42
class Service (ABC ):
43
+ """The abstract base class for all service objects. Services typically launch a child program
44
+ in a new process as an interim process to communicate with a browser.
45
+
46
+ :param executable: install path of the executable.
47
+ :param port: Port for the service to run on, defaults to 0 where the operating system will decide.
48
+ :param log_file: (Optional) file descriptor (pos int) or file object with a valid file descriptor.
49
+ subprocess.PIPE & subprocess.DEVNULL are also valid values.
50
+ :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
51
+ """
52
+
42
53
def __init__ (
43
54
self ,
44
55
executable : str ,
56
+ start_error_message : str ,
45
57
port : int = 0 ,
46
- log_file = DEVNULL ,
47
- env : typing .Optional [typing .Dict [typing .Any , typing .Any ]] = None ,
48
- start_error_message : str = "" ,
58
+ log_file : SubprocessStdAlias = DEVNULL ,
59
+ env : typing .Optional [typing .Mapping [typing .Any , typing .Any ]] = None ,
49
60
) -> None :
50
61
self .path = executable
51
62
self .port = port or utils .free_port ()
@@ -65,6 +76,7 @@ def service_url(self) -> str:
65
76
66
77
@abstractmethod
67
78
def command_line_args (self ) -> typing .List [str ]:
79
+ """A List of program arguments (excluding the executable)."""
68
80
raise NotImplementedError ("This method needs to be implemented in a sub class" )
69
81
70
82
def start (self ) -> None :
0 commit comments