moving to scripts
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,50 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
from selenium.webdriver.chromium.options import ChromiumOptions
|
||||
|
||||
|
||||
class Options(ChromiumOptions):
|
||||
KEY = "ms:edgeOptions"
|
||||
|
||||
def __init__(self):
|
||||
super(Options, self).__init__()
|
||||
self._use_webview = False
|
||||
|
||||
@property
|
||||
def use_webview(self) -> bool:
|
||||
return self._use_webview
|
||||
|
||||
@use_webview.setter
|
||||
def use_webview(self, value: bool):
|
||||
self._use_webview = bool(value)
|
||||
|
||||
def to_capabilities(self) -> dict:
|
||||
"""
|
||||
Creates a capabilities with all the options that have been set and
|
||||
:Returns: A dictionary with everything
|
||||
"""
|
||||
caps = super(Options, self).to_capabilities()
|
||||
if self._use_webview:
|
||||
caps['browserName'] = 'webview2'
|
||||
|
||||
return caps
|
||||
|
||||
@property
|
||||
def default_capabilities(self) -> dict:
|
||||
return DesiredCapabilities.EDGE.copy()
|
||||
@@ -0,0 +1,51 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from typing import List
|
||||
from selenium.webdriver.chromium import service
|
||||
|
||||
|
||||
class Service(service.ChromiumService):
|
||||
|
||||
def __init__(self, executable_path: str, port: int = 0, verbose: bool = False, log_path: str = None,
|
||||
service_args: List[str] = None, env=None):
|
||||
"""
|
||||
Creates a new instance of the EdgeDriver service.
|
||||
EdgeDriver provides an interface for Microsoft WebDriver to use
|
||||
with Microsoft Edge.
|
||||
|
||||
:Args:
|
||||
- executable_path : Path to the Microsoft WebDriver binary.
|
||||
- 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.
|
||||
- log_path : Optional path for the webdriver binary to log to. Defaults to None which disables logging.
|
||||
- service_args : List of args to pass to the WebDriver service.
|
||||
"""
|
||||
self.service_args = service_args or []
|
||||
|
||||
if verbose:
|
||||
self.service_args.append("--verbose")
|
||||
|
||||
super(Service, self).__init__(
|
||||
executable_path,
|
||||
port,
|
||||
service_args,
|
||||
log_path,
|
||||
env,
|
||||
"Please download from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/")
|
||||
@@ -0,0 +1,67 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import warnings
|
||||
from selenium.webdriver.chromium.webdriver import ChromiumDriver
|
||||
from .options import Options
|
||||
from .service import Service
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
|
||||
DEFAULT_PORT = 0
|
||||
DEFAULT_SERVICE_LOG_PATH = None
|
||||
|
||||
|
||||
class WebDriver(ChromiumDriver):
|
||||
"""
|
||||
Controls the Microsoft Edge driver and allows you to drive the browser.
|
||||
You will need to download the MSEdgeDriver (Chromium) executable from
|
||||
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
|
||||
"""
|
||||
|
||||
def __init__(self, executable_path='msedgedriver', port=DEFAULT_PORT,
|
||||
options: Options = Options(), service_args=None,
|
||||
capabilities=None, service_log_path=DEFAULT_SERVICE_LOG_PATH,
|
||||
service: Service = None, keep_alive=False, verbose=False):
|
||||
"""
|
||||
Creates a new instance of the edge driver.
|
||||
Starts the service and then creates new instance of edge driver.
|
||||
|
||||
:Args:
|
||||
- executable_path - Deprecated: path to the executable. If the default is used it assumes the executable is in the $PATH
|
||||
- port - Deprecated: port you would like the service to run, if left as 0, a free port will be found.
|
||||
- options - this takes an instance of EdgeOptions
|
||||
- service_args - Deprecated: List of args to pass to the driver service
|
||||
- capabilities - Deprecated: Dictionary object with non-browser specific
|
||||
capabilities only, such as "proxy" or "loggingPref".
|
||||
- service_log_path - Deprecated: Where to log information from the driver.
|
||||
- keep_alive - Whether to configure EdgeRemoteConnection to use HTTP keep-alive.
|
||||
- verbose - whether to set verbose logging in the service.
|
||||
"""
|
||||
if executable_path != 'msedgedriver':
|
||||
warnings.warn('executable_path has been deprecated, please pass in a Service object',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
if not service:
|
||||
service = Service(executable_path, port, service_args, service_log_path)
|
||||
|
||||
super(WebDriver, self).__init__(DesiredCapabilities.EDGE['browserName'], "ms",
|
||||
port, options,
|
||||
service_args, capabilities,
|
||||
service_log_path, service, keep_alive)
|
||||
|
||||
def create_options(self) -> Options:
|
||||
return Options()
|
||||
Reference in New Issue
Block a user