|
15 | 15 | # specific language governing permissions and limitations
|
16 | 16 | # under the License.
|
17 | 17 |
|
18 |
| -from subprocess import PIPE |
19 | 18 | from selenium.webdriver.common import service
|
20 | 19 |
|
21 | 20 |
|
22 | 21 | class Service(service.Service):
|
23 |
| - def __init__(self, executable_path, port=0, log_file=PIPE): |
24 |
| - service.Service.__init__(self, executable_path, port=port, log_file=log_file, |
25 |
| - start_error_message="Please download from http://go.microsoft.com/fwlink/?LinkId=619687 ") |
| 22 | + |
| 23 | + def __init__(self, executable_path, port=0, verbose=False, log_path=None): |
| 24 | + """ |
| 25 | + Creates a new instance of the EdgeDriver service. |
| 26 | +
|
| 27 | + EdgeDriver provides an interface for Microsoft WebDriver to use |
| 28 | + with Microsoft Edge. |
| 29 | +
|
| 30 | + :param executable_path: Path to the Microsoft WebDriver binary. |
| 31 | + :param port: Run the remote service on a specified port. |
| 32 | + Defaults to 0, which binds to a random open port of the |
| 33 | + system's choosing. |
| 34 | + :verbose: Whether to make the webdriver more verbose (passes the |
| 35 | + --verbose option to the binary). Defaults to False. |
| 36 | + :param log_path: Optional path for the webdriver binary to log to. |
| 37 | + Defaults to None which disables logging. |
| 38 | +
|
| 39 | + """ |
| 40 | + |
| 41 | + self.service_args = [] |
| 42 | + if verbose: |
| 43 | + self.service_args.append("--verbose") |
| 44 | + |
| 45 | + params = { |
| 46 | + "executable": executable_path, |
| 47 | + "port": port, |
| 48 | + "start_error_message": "Please download from http://go.microsoft.com/fwlink/?LinkId=619687" |
| 49 | + } |
| 50 | + |
| 51 | + if log_path: |
| 52 | + params["log_file"] = open(log_path, "a+") |
| 53 | + |
| 54 | + service.Service.__init__(self, **params) |
26 | 55 |
|
27 | 56 | def command_line_args(self):
|
28 |
| - return ["--port=%d" % self.port] |
| 57 | + return ["--port=%d" % self.port] + self.service_args |
0 commit comments