17
17
18
18
import base64
19
19
import os
20
+ from typing import List , NoReturn , Union
20
21
21
22
from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
22
23
from selenium .webdriver .common .options import ArgOptions
@@ -34,14 +35,14 @@ def __init__(self):
34
35
self ._debugger_address = None
35
36
36
37
@property
37
- def binary_location (self ):
38
+ def binary_location (self ) -> str :
38
39
"""
39
40
:Returns: The location of the binary, otherwise an empty string
40
41
"""
41
42
return self ._binary_location
42
43
43
44
@binary_location .setter
44
- def binary_location (self , value ):
45
+ def binary_location (self , value : str ):
45
46
"""
46
47
Allows you to set where the chromium binary lives
47
48
:Args:
@@ -50,14 +51,14 @@ def binary_location(self, value):
50
51
self ._binary_location = value
51
52
52
53
@property
53
- def debugger_address (self ):
54
+ def debugger_address (self : str ):
54
55
"""
55
56
:Returns: The address of the remote devtools instance
56
57
"""
57
58
return self ._debugger_address
58
59
59
60
@debugger_address .setter
60
- def debugger_address (self , value ):
61
+ def debugger_address (self , value : str ):
61
62
"""
62
63
Allows you to set the address of the remote devtools instance
63
64
that the ChromeDriver instance will try to connect to during an
@@ -68,7 +69,7 @@ def debugger_address(self, value):
68
69
self ._debugger_address = value
69
70
70
71
@property
71
- def extensions (self ):
72
+ def extensions (self ) -> List [ str ] :
72
73
"""
73
74
:Returns: A list of encoded extensions that will be loaded
74
75
"""
@@ -83,7 +84,7 @@ def extensions(self):
83
84
file_ .close ()
84
85
return encoded_extensions + self ._extensions
85
86
86
- def add_extension (self , extension ) :
87
+ def add_extension (self , extension : str ) -> NoReturn :
87
88
"""
88
89
Adds the path to the extension to a list that will be used to extract it
89
90
to the ChromeDriver
@@ -100,7 +101,7 @@ def add_extension(self, extension):
100
101
else :
101
102
raise ValueError ("argument can not be null" )
102
103
103
- def add_encoded_extension (self , extension ) :
104
+ def add_encoded_extension (self , extension : str ) -> NoReturn :
104
105
"""
105
106
Adds Base64 encoded string with extension data to a list that will be used to extract it
106
107
to the ChromeDriver
@@ -114,13 +115,13 @@ def add_encoded_extension(self, extension):
114
115
raise ValueError ("argument can not be null" )
115
116
116
117
@property
117
- def experimental_options (self ):
118
+ def experimental_options (self ) -> dict :
118
119
"""
119
120
:Returns: A dictionary of experimental options for chromium
120
121
"""
121
122
return self ._experimental_options
122
123
123
- def add_experimental_option (self , name , value ):
124
+ def add_experimental_option (self , name : str , value : Union [ str , int ] ):
124
125
"""
125
126
Adds an experimental option which is passed to chromium.
126
127
@@ -131,14 +132,14 @@ def add_experimental_option(self, name, value):
131
132
self ._experimental_options [name ] = value
132
133
133
134
@property
134
- def headless (self ):
135
+ def headless (self ) -> bool :
135
136
"""
136
137
:Returns: True if the headless argument is set, else False
137
138
"""
138
139
return '--headless' in self ._arguments
139
140
140
141
@headless .setter
141
- def headless (self , value ):
142
+ def headless (self , value : bool ):
142
143
"""
143
144
Sets the headless argument
144
145
:Args:
@@ -151,17 +152,17 @@ def headless(self, value):
151
152
self ._arguments = list (set (self ._arguments ) - args )
152
153
153
154
@property
154
- def page_load_strategy (self ):
155
+ def page_load_strategy (self ) -> str :
155
156
return self ._caps ["pageLoadStrategy" ]
156
157
157
158
@page_load_strategy .setter
158
- def page_load_strategy (self , strategy ):
159
+ def page_load_strategy (self , strategy : str ):
159
160
if strategy in ["normal" , "eager" , "none" ]:
160
161
self .set_capability ("pageLoadStrategy" , strategy )
161
162
else :
162
163
raise ValueError ("Strategy can only be one of the following: normal, eager, none" )
163
164
164
- def to_capabilities (self ):
165
+ def to_capabilities (self ) -> dict :
165
166
"""
166
167
Creates a capabilities with all the options that have been set
167
168
:Returns: A dictionary with everything
@@ -180,5 +181,5 @@ def to_capabilities(self):
180
181
return caps
181
182
182
183
@property
183
- def default_capabilities (self ):
184
+ def default_capabilities (self ) -> dict :
184
185
return DesiredCapabilities .CHROME .copy ()
0 commit comments