Skip to content

Commit

Permalink
[py] EdgeDriver with log file and verbose option
Browse files Browse the repository at this point in the history
  • Loading branch information
Herst authored and AutomatedTester committed Nov 2, 2016
1 parent d266b00 commit 363fcda
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
39 changes: 34 additions & 5 deletions py/selenium/webdriver/edge/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,43 @@
# specific language governing permissions and limitations
# under the License.

from subprocess import PIPE
from selenium.webdriver.common import service


class Service(service.Service):
def __init__(self, executable_path, port=0, log_file=PIPE):
service.Service.__init__(self, executable_path, port=port, log_file=log_file,
start_error_message="Please download from http://go.microsoft.com/fwlink/?LinkId=619687 ")

def __init__(self, executable_path, port=0, verbose=False, log_path=None):
"""
Creates a new instance of the EdgeDriver service.
EdgeDriver provides an interface for Microsoft WebDriver to use
with Microsoft Edge.
:param executable_path: Path to the Microsoft WebDriver binary.
:param port: Run the remote service on a specified port.
Defaults to 0, which binds to a random open port of the
system's choosing.
:verbose: Whether to make the webdriver more verbose (passes the
--verbose option to the binary). Defaults to False.
:param log_path: Optional path for the webdriver binary to log to.
Defaults to None which disables logging.
"""

self.service_args = []
if verbose:
self.service_args.append("--verbose")

params = {
"executable": executable_path,
"port": port,
"start_error_message": "Please download from http://go.microsoft.com/fwlink/?LinkId=619687"
}

if log_path:
params["log_file"] = open(log_path, "a+")

service.Service.__init__(self, **params)

def command_line_args(self):
return ["--port=%d" % self.port]
return ["--port=%d" % self.port] + self.service_args
4 changes: 2 additions & 2 deletions py/selenium/webdriver/edge/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
class WebDriver(RemoteWebDriver):

def __init__(self, executable_path='MicrosoftWebDriver.exe',
capabilities=None, port=0):
capabilities=None, port=0, verbose=False, log_path=None):
self.port = port
if self.port == 0:
self.port = utils.free_port()

self.edge_service = Service(executable_path, port=self.port)
self.edge_service = Service(executable_path, port=self.port, verbose=verbose, log_path=log_path)
self.edge_service.start()

if capabilities is None:
Expand Down

0 comments on commit 363fcda

Please sign in to comment.