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,29 @@
|
||||
# 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.chromium.options import ChromiumOptions
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
|
||||
class Options(ChromiumOptions):
|
||||
|
||||
@property
|
||||
def default_capabilities(self) -> dict:
|
||||
return DesiredCapabilities.CHROME.copy()
|
||||
|
||||
def enable_mobile(self, android_package="com.android.chrome", android_activity=None, device_serial=None):
|
||||
super().enable_mobile(android_package, android_activity, device_serial)
|
||||
@@ -0,0 +1,44 @@
|
||||
# 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):
|
||||
"""
|
||||
Object that manages the starting and stopping of the ChromeDriver
|
||||
"""
|
||||
|
||||
def __init__(self, executable_path: str, port: int = 0, service_args: List[str] = None,
|
||||
log_path: str = None, env: str = None):
|
||||
"""
|
||||
Creates a new instance of the Service
|
||||
|
||||
:Args:
|
||||
- executable_path : Path to the ChromeDriver
|
||||
- port : Port the service is running on
|
||||
- service_args : List of args to pass to the chromedriver service
|
||||
- log_path : Path for the chromedriver service to log to"""
|
||||
|
||||
super(Service, self).__init__(
|
||||
executable_path,
|
||||
port,
|
||||
service_args,
|
||||
log_path,
|
||||
env,
|
||||
"Please see https://chromedriver.chromium.org/home")
|
||||
@@ -0,0 +1,72 @@
|
||||
# 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
|
||||
DEFAULT_KEEP_ALIVE = None
|
||||
|
||||
|
||||
class WebDriver(ChromiumDriver):
|
||||
"""
|
||||
Controls the ChromeDriver and allows you to drive the browser.
|
||||
You will need to download the ChromeDriver executable from
|
||||
http://chromedriver.storage.googleapis.com/index.html
|
||||
"""
|
||||
|
||||
def __init__(self, executable_path="chromedriver", port=DEFAULT_PORT,
|
||||
options: Options = None, service_args=None,
|
||||
desired_capabilities=None, service_log_path=DEFAULT_SERVICE_LOG_PATH,
|
||||
chrome_options=None, service: Service = None, keep_alive=DEFAULT_KEEP_ALIVE):
|
||||
"""
|
||||
Creates a new instance of the chrome driver.
|
||||
Starts the service and then creates new instance of chrome 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 ChromeOptions
|
||||
- service_args - Deprecated: List of args to pass to the driver service
|
||||
- desired_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 - Deprecated: Whether to configure ChromeRemoteConnection to use HTTP keep-alive.
|
||||
"""
|
||||
if executable_path != 'chromedriver':
|
||||
warnings.warn('executable_path has been deprecated, please pass in a Service object',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
if chrome_options:
|
||||
warnings.warn('use options instead of chrome_options',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
options = chrome_options
|
||||
if keep_alive != DEFAULT_KEEP_ALIVE:
|
||||
warnings.warn('keep_alive has been deprecated, please pass in a Service object',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
else:
|
||||
keep_alive = True
|
||||
if not service:
|
||||
service = Service(executable_path, port, service_args, service_log_path)
|
||||
|
||||
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
|
||||
port, options,
|
||||
service_args, desired_capabilities,
|
||||
service_log_path, service, keep_alive)
|
||||
Reference in New Issue
Block a user