Skip to content

Commit 363fcda

Browse files
HerstAutomatedTester
authored andcommitted
[py] EdgeDriver with log file and verbose option
1 parent d266b00 commit 363fcda

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

py/selenium/webdriver/edge/service.py

+34-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,43 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from subprocess import PIPE
1918
from selenium.webdriver.common import service
2019

2120

2221
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)
2655

2756
def command_line_args(self):
28-
return ["--port=%d" % self.port]
57+
return ["--port=%d" % self.port] + self.service_args

py/selenium/webdriver/edge/webdriver.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
class WebDriver(RemoteWebDriver):
2626

2727
def __init__(self, executable_path='MicrosoftWebDriver.exe',
28-
capabilities=None, port=0):
28+
capabilities=None, port=0, verbose=False, log_path=None):
2929
self.port = port
3030
if self.port == 0:
3131
self.port = utils.free_port()
3232

33-
self.edge_service = Service(executable_path, port=self.port)
33+
self.edge_service = Service(executable_path, port=self.port, verbose=verbose, log_path=log_path)
3434
self.edge_service.start()
3535

3636
if capabilities is None:

0 commit comments

Comments
 (0)