QWeb 3.3.2__tar.gz → 3.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {QWeb-3.3.2 → QWeb-3.4.0}/PKG-INFO +4 -3
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/_version.py +3 -3
- QWeb-3.4.0/QWeb/internal/browser/chrome.py +163 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/browser/edge.py +8 -2
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/browser/firefox.py +11 -2
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/browser/safari.py +9 -4
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/checkbox.py +1 -1
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/frame.py +65 -20
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/browser.py +7 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/config.py +32 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/element.py +10 -1
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/frame.py +3 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/text.py +4 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb.egg-info/PKG-INFO +4 -3
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb.egg-info/requires.txt +11 -6
- {QWeb-3.3.2 → QWeb-3.4.0}/setup.py +10 -8
- {QWeb-3.3.2 → QWeb-3.4.0}/versioneer.py +10 -3
- QWeb-3.3.2/QWeb/internal/browser/chrome.py +0 -137
- {QWeb-3.3.2 → QWeb-3.4.0}/LICENSE +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/MANIFEST.in +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/__init__.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/__main__.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/custom_config.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/__init__.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/actions.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/ajax.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/alert.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/blocks.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/browser/__init__.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/browser/android.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/browser/bs_desktop.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/browser/bs_mobile.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/config.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/config_defaults.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/cookies.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/decorators.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/download.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/dragdrop.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/dropdown.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/element.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/exceptions.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/file.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/frame_checker.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/icon.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/input_.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/input_handler.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/javascript.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/lists.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/meas.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/platform.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/screenshot.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/search_strategy.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/secrets.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/table.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/text.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/user.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/util.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/window.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/internal/xhr.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/__init__.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/ajax.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/alert.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/blocks.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/checkbox.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/cookies.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/debug.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/download.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/dragdrop.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/dropdown.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/file.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/icon.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/input_.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/javascript.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/lists.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/screenshot.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/search_strategy.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/table.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb/keywords/window.py +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb.egg-info/SOURCES.txt +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb.egg-info/dependency_links.txt +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb.egg-info/not-zip-safe +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/QWeb.egg-info/top_level.txt +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/README.md +0 -0
- {QWeb-3.3.2 → QWeb-3.4.0}/setup.cfg +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: QWeb
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Keyword driven automation for the web
|
|
5
5
|
Home-page: https://github.com/qentinelqi/qweb/
|
|
6
|
-
Author:
|
|
7
|
-
Author-email:
|
|
6
|
+
Author: Copado Inc.
|
|
7
|
+
Author-email: copadorobotictesting@copado.com
|
|
8
8
|
License: Apache License 2.0
|
|
9
9
|
Keywords: test automation robot framework
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.8
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.9
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
15
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
16
|
Classifier: Framework :: Robot Framework
|
|
16
17
|
Classifier: Framework :: Robot Framework :: Library
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2024-
|
|
11
|
+
"date": "2024-08-22T09:48:50+0300",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "v3.
|
|
14
|
+
"full-revisionid": "f1673956e04b38acaf9db52bbaec1ac4645fe0e8",
|
|
15
|
+
"version": "v3.4.0"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import os
|
|
3
|
+
from typing import Optional, Any
|
|
4
|
+
from selenium.webdriver.remote.webdriver import WebDriver
|
|
5
|
+
from selenium.webdriver import Chrome
|
|
6
|
+
from selenium.webdriver.chrome.options import Options
|
|
7
|
+
from selenium.webdriver.chrome.service import Service
|
|
8
|
+
from robot.api import logger
|
|
9
|
+
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
|
|
10
|
+
from QWeb.internal import browser, user, util
|
|
11
|
+
from QWeb.internal.config_defaults import CONFIG
|
|
12
|
+
|
|
13
|
+
NAMES: list[str] = ["chrome", "gc"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def check_browser_reuse(**kwargs: Any) -> tuple[bool, Optional[str], Optional[str]]:
|
|
17
|
+
try:
|
|
18
|
+
browser_reuse = util.par2bool(util.get_rfw_variable_value("${BROWSER_REUSE}")) or False
|
|
19
|
+
dbg_addr = kwargs.get("debugger_address", None) or util.get_rfw_variable_value(
|
|
20
|
+
"${BROWSER_DEBUGGER_ADDRESS}"
|
|
21
|
+
)
|
|
22
|
+
executor_url = kwargs.get("executor_url", None) or util.get_rfw_variable_value(
|
|
23
|
+
"${BROWSER_EXECUTOR_URL}"
|
|
24
|
+
)
|
|
25
|
+
return browser_reuse, dbg_addr, executor_url
|
|
26
|
+
except RobotNotRunningError:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
return False, None, None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def write_browser_session_argsfile(
|
|
33
|
+
dbg_addr: str, executor_url: str, fname: str = "browser_session.arg"
|
|
34
|
+
) -> str:
|
|
35
|
+
robot_output = util.get_rfw_variable_value("${OUTPUT DIR}")
|
|
36
|
+
args_fn = os.path.join(robot_output or os.getcwd(), fname)
|
|
37
|
+
with open(args_fn, "w") as args_file:
|
|
38
|
+
args_file.write(f"-v BROWSER_REUSE:{True}{os.linesep}")
|
|
39
|
+
args_file.write(f"-v BROWSER_DEBUGGER_ADDRESS:{dbg_addr}{os.linesep}")
|
|
40
|
+
args_file.write(f"-v BROWSER_EXECUTOR_URL:{executor_url}{os.linesep}")
|
|
41
|
+
|
|
42
|
+
return args_fn
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def open_browser(
|
|
46
|
+
executable_path: str = "", chrome_args: Optional[list[str]] = None, **kwargs: Any
|
|
47
|
+
) -> WebDriver:
|
|
48
|
+
"""Open Chrome browser instance and cache the driver.
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
executable_path : str (Default "chromedriver")
|
|
53
|
+
path to the executable. If the default is used it assumes the
|
|
54
|
+
executable is in the $PATH.
|
|
55
|
+
port : int (Default 0)
|
|
56
|
+
port you would like the service to run, if left as 0, a free port will
|
|
57
|
+
be found.
|
|
58
|
+
desired_capabilities : dict (Default None)
|
|
59
|
+
Dictionary object with non-browser specific capabilities only, such as
|
|
60
|
+
"proxy" or "loggingPref".
|
|
61
|
+
chrome_args : Optional arguments to modify browser settings
|
|
62
|
+
"""
|
|
63
|
+
options = create_chrome_options(chrome_args, **kwargs)
|
|
64
|
+
chromedriver_path = resolve_chromedriver_path(executable_path)
|
|
65
|
+
|
|
66
|
+
browser_reuse, debugger_address, executor_url = check_browser_reuse(**kwargs)
|
|
67
|
+
logger.debug(
|
|
68
|
+
f"browser_reuse: {browser_reuse}, "
|
|
69
|
+
f"executor_url: {executor_url}, "
|
|
70
|
+
f"debugger_address: {debugger_address}"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if browser_reuse and executor_url and debugger_address:
|
|
74
|
+
return create_reused_browser(debugger_address)
|
|
75
|
+
|
|
76
|
+
driver = create_new_browser(chromedriver_path, options, **kwargs)
|
|
77
|
+
cache_browser_session(driver)
|
|
78
|
+
|
|
79
|
+
browser.cache_browser(driver)
|
|
80
|
+
return driver
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def create_chrome_options(chrome_args: Optional[list[str]], **kwargs: Any) -> Options:
|
|
84
|
+
"""Create Chrome options based on arguments and keyword arguments."""
|
|
85
|
+
options = Options()
|
|
86
|
+
options.add_experimental_option("excludeSwitches", ["enable-logging"])
|
|
87
|
+
|
|
88
|
+
if chrome_args:
|
|
89
|
+
if any("headless" in arg.lower() for arg in chrome_args):
|
|
90
|
+
CONFIG.set_value("Headless", True)
|
|
91
|
+
for arg in chrome_args:
|
|
92
|
+
options.add_argument(arg.lstrip())
|
|
93
|
+
|
|
94
|
+
options.add_argument("start-maximized")
|
|
95
|
+
options.add_argument("--disable-notifications")
|
|
96
|
+
options.add_argument("--disable-search-engine-choice-screen")
|
|
97
|
+
|
|
98
|
+
if "headless" in kwargs:
|
|
99
|
+
CONFIG.set_value("Headless", True)
|
|
100
|
+
options.add_argument("headless")
|
|
101
|
+
|
|
102
|
+
if "prefs" in kwargs:
|
|
103
|
+
prefs = util.parse_prefs(kwargs.get("prefs"))
|
|
104
|
+
options.add_experimental_option("prefs", prefs)
|
|
105
|
+
|
|
106
|
+
if "emulation" in kwargs:
|
|
107
|
+
emulate_device = util.get_emulation_pref(kwargs["emulation"])
|
|
108
|
+
options.add_experimental_option("mobileEmulation", emulate_device)
|
|
109
|
+
|
|
110
|
+
chrome_path = kwargs.get("chrome_path", None) or util.get_rfw_variable_value("${CHROME_PATH}")
|
|
111
|
+
if chrome_path:
|
|
112
|
+
options.binary_location = chrome_path
|
|
113
|
+
|
|
114
|
+
chrome_version = (
|
|
115
|
+
kwargs.get("browser_version", None)
|
|
116
|
+
or util.get_rfw_variable_value("${BROWSER_VERSION}")
|
|
117
|
+
)
|
|
118
|
+
if chrome_version:
|
|
119
|
+
options.browser_version = chrome_version
|
|
120
|
+
|
|
121
|
+
if user.is_root():
|
|
122
|
+
options.add_argument("no-sandbox")
|
|
123
|
+
|
|
124
|
+
return options
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def resolve_chromedriver_path(executable_path: str) -> str:
|
|
128
|
+
"""Resolve the path to the ChromeDriver executable."""
|
|
129
|
+
driver_path = util.get_rfw_variable_value("${CHROMEDRIVER_PATH}") or executable_path
|
|
130
|
+
if driver_path:
|
|
131
|
+
logger.debug(f"Chromedriver path: {driver_path}")
|
|
132
|
+
return driver_path
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def create_reused_browser(debugger_address: str) -> WebDriver:
|
|
136
|
+
"""Create a browser instance reusing an existing session."""
|
|
137
|
+
options = Options()
|
|
138
|
+
options.add_argument("headless")
|
|
139
|
+
options.debugger_address = debugger_address
|
|
140
|
+
service = Service()
|
|
141
|
+
return Chrome(service=service, options=options)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def create_new_browser(chromedriver_path: str, options: Options, **kwargs: Any) -> WebDriver:
|
|
145
|
+
"""Create a new browser instance."""
|
|
146
|
+
remote_url = kwargs.get("remote_url", None)
|
|
147
|
+
if remote_url:
|
|
148
|
+
return WebDriver(command_executor=remote_url, options=options)
|
|
149
|
+
|
|
150
|
+
service = Service(chromedriver_path) if chromedriver_path else Service()
|
|
151
|
+
return Chrome(service=service, options=options)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def cache_browser_session(driver: WebDriver) -> None:
|
|
155
|
+
"""Cache the WebDriver session info for reuse."""
|
|
156
|
+
browser_reuse_enabled = (
|
|
157
|
+
util.par2bool(util.get_rfw_variable_value("${BROWSER_REUSE_ENABLED}")) or False
|
|
158
|
+
)
|
|
159
|
+
if browser_reuse_enabled:
|
|
160
|
+
dbg_address = driver.capabilities["goog:chromeOptions"]["debuggerAddress"]
|
|
161
|
+
write_browser_session_argsfile(dbg_address, driver.command_executor._url) # type: ignore # pylint: disable=protected-access
|
|
162
|
+
BuiltIn().set_global_variable("${BROWSER_EXECUTOR_URL}", None)
|
|
163
|
+
BuiltIn().set_global_variable("${BROWSER_DEBUGGER_ADDRESS}", None)
|
|
@@ -51,6 +51,8 @@ def open_browser(
|
|
|
51
51
|
# parameters instead of opening new chrome session.
|
|
52
52
|
# New Remote Web Driver is created in headless mode.
|
|
53
53
|
edgedriver_path = util.get_rfw_variable_value("${EDGEDRIVER_PATH}") or executable_path
|
|
54
|
+
if edgedriver_path:
|
|
55
|
+
logger.debug(f"Edgedriver path: {edgedriver_path}")
|
|
54
56
|
edge_path = kwargs.get("edge_path", None) or util.get_rfw_variable_value("${EDGE_PATH}")
|
|
55
57
|
if edge_path:
|
|
56
58
|
options.binary_location = edge_path # pylint: disable=no-member
|
|
@@ -84,8 +86,12 @@ def open_browser(
|
|
|
84
86
|
emulate_device = util.get_emulation_pref(emulation)
|
|
85
87
|
options.add_experimental_option("mobileEmulation", emulate_device)
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
remote_url = kwargs.get("remote_url", None)
|
|
90
|
+
if remote_url:
|
|
91
|
+
driver = WebDriver(command_executor=remote_url, options=options)
|
|
92
|
+
else:
|
|
93
|
+
service = Service(edgedriver_path) if edgedriver_path else Service()
|
|
94
|
+
driver = Edge(service=service, options=options)
|
|
89
95
|
|
|
90
96
|
# driver = Edge(
|
|
91
97
|
# util.get_rfw_variable_value('${EDGEDRIVER_PATH}') # pylint: disable=unexpected-keyword-arg
|
|
@@ -104,8 +104,17 @@ def open_browser(
|
|
|
104
104
|
|
|
105
105
|
if binary:
|
|
106
106
|
options.binary_location = binary
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
|
|
108
|
+
remote_url = kwargs.get("remote_url", None)
|
|
109
|
+
if remote_url:
|
|
110
|
+
driver = WebDriver(command_executor=remote_url, options=options)
|
|
111
|
+
else:
|
|
112
|
+
service = (
|
|
113
|
+
Service(driver_path, log_path=log_path)
|
|
114
|
+
if driver_path
|
|
115
|
+
else Service(log_path=log_path)
|
|
116
|
+
)
|
|
117
|
+
driver = webdriver.Firefox(service=service, options=options)
|
|
109
118
|
if os.name == "nt": # Maximize window if running on windows, doesn't work on linux
|
|
110
119
|
driver.maximize_window()
|
|
111
120
|
browser.cache_browser(driver)
|
|
@@ -17,6 +17,7 @@ def open_browser(
|
|
|
17
17
|
driver_path: str = "",
|
|
18
18
|
desired_capabilities: Optional[dict[str, Any]] = None,
|
|
19
19
|
quiet: bool = False,
|
|
20
|
+
**kwargs: Any,
|
|
20
21
|
) -> WebDriver:
|
|
21
22
|
options = Options()
|
|
22
23
|
|
|
@@ -36,12 +37,16 @@ def open_browser(
|
|
|
36
37
|
"OpenBrowser\thttps://www.google.com\tsafari\tdesired_capabilities=${caps}"
|
|
37
38
|
)
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
remote_url = kwargs.get("remote_url", None)
|
|
41
|
+
if remote_url:
|
|
42
|
+
driver = WebDriver(command_executor=remote_url, options=options)
|
|
41
43
|
else:
|
|
42
|
-
|
|
44
|
+
if driver_path:
|
|
45
|
+
service = Service(driver_path, port=port, quiet=quiet)
|
|
46
|
+
else:
|
|
47
|
+
service = Service(port=port, quiet=quiet)
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
driver = webdriver.Safari(service=service, options=options)
|
|
45
50
|
|
|
46
51
|
# If implicit_wait is not > 0 Safaridriver starts raising TimeoutExceptions
|
|
47
52
|
# instead of proper exception types
|
|
@@ -119,7 +119,7 @@ def get_checkbox_elements_from_all_documents(
|
|
|
119
119
|
locator, anchor=anchor, index=index, **kwargs
|
|
120
120
|
)
|
|
121
121
|
if not checkbox_element:
|
|
122
|
-
checkbox_element, locator_element = get_checkbox_by_locator(locator, anchor
|
|
122
|
+
checkbox_element, locator_element = get_checkbox_by_locator(locator, anchor)
|
|
123
123
|
if checkbox_element:
|
|
124
124
|
return checkbox_element, locator_element
|
|
125
125
|
raise QWebElementNotFoundError("No matching element found")
|
|
@@ -175,38 +175,54 @@ def set_html_source_count(value: Union[int, str]):
|
|
|
175
175
|
def all_frames(fn: Callable[..., Any]) -> Callable[..., Any]:
|
|
176
176
|
"""Decorator that takes any func as a parameter.
|
|
177
177
|
|
|
178
|
-
search_from_frames is recursive function
|
|
179
|
-
all found frames until we find our element if
|
|
180
|
-
main
|
|
178
|
+
search_from_frames is a recursive function that goes through
|
|
179
|
+
all found frames until we find our element if it's not in
|
|
180
|
+
the main HTML's DOM tree.
|
|
181
181
|
"""
|
|
182
182
|
|
|
183
183
|
@wraps(fn)
|
|
184
184
|
def wrapped(*args, **kwargs) -> Callable[..., Any]:
|
|
185
|
+
# Default behavior is not to continue searching
|
|
186
|
+
continue_search = kwargs.get("continue_search", False)
|
|
187
|
+
|
|
188
|
+
# pylint: disable=too-many-branches
|
|
185
189
|
def search_from_frames(
|
|
186
190
|
driver: Optional[WebDriver] = None, current_frame: Optional[WebElement] = None
|
|
187
191
|
) -> Callable[..., Any]:
|
|
192
|
+
# Initialize the list to store found elements if continue_search is True
|
|
193
|
+
all_elements = []
|
|
188
194
|
keep_frame = kwargs.get("stay_in_current_frame", CONFIG["StayInCurrentFrame"])
|
|
189
195
|
if keep_frame:
|
|
190
196
|
return fn(*args, **kwargs)
|
|
197
|
+
|
|
191
198
|
err = None
|
|
192
199
|
if not driver:
|
|
193
200
|
driver = browser.get_current_browser()
|
|
194
201
|
driver.switch_to.default_content()
|
|
202
|
+
|
|
195
203
|
if current_frame:
|
|
196
204
|
try:
|
|
197
205
|
driver.switch_to.frame(current_frame)
|
|
198
|
-
logger.debug("
|
|
206
|
+
logger.debug(f"Switching to child frame {str(fn)}")
|
|
199
207
|
except (StaleElementReferenceException, WebDriverException) as e:
|
|
200
208
|
logger.debug(str(e))
|
|
201
209
|
driver.switch_to.default_content()
|
|
202
210
|
raise e
|
|
211
|
+
|
|
203
212
|
try:
|
|
204
213
|
web_element = fn(*args, **kwargs)
|
|
205
214
|
except QWebElementNotFoundError as e:
|
|
206
215
|
err = e
|
|
207
216
|
web_element = None
|
|
217
|
+
|
|
208
218
|
if is_valid(web_element):
|
|
209
|
-
|
|
219
|
+
if not continue_search:
|
|
220
|
+
return web_element
|
|
221
|
+
if not isinstance(web_element, tuple):
|
|
222
|
+
web_element = list(web_element)
|
|
223
|
+
# Accumulate elements if continuing search
|
|
224
|
+
all_elements.extend(web_element)
|
|
225
|
+
|
|
210
226
|
start = time.time()
|
|
211
227
|
timeout = CONFIG["FrameTimeout"]
|
|
212
228
|
while time.time() < timeout + start:
|
|
@@ -214,65 +230,88 @@ def all_frames(fn: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
214
230
|
for frame in frames:
|
|
215
231
|
web_element = search_from_frames(driver=driver, current_frame=frame)
|
|
216
232
|
if is_valid(web_element):
|
|
217
|
-
logger.debug("Found
|
|
218
|
-
|
|
233
|
+
logger.debug(f"Found web element = {web_element}")
|
|
234
|
+
if not continue_search:
|
|
235
|
+
return web_element
|
|
236
|
+
if not isinstance(web_element, tuple):
|
|
237
|
+
web_element = list(web_element)
|
|
238
|
+
all_elements.extend(web_element) # Accumulate elements if continuing search
|
|
239
|
+
|
|
219
240
|
try:
|
|
220
241
|
driver.switch_to.parent_frame()
|
|
221
242
|
except WebDriverException as e:
|
|
222
243
|
driver.switch_to.default_content()
|
|
223
244
|
raise e
|
|
245
|
+
|
|
224
246
|
config.set_config("FrameTimeout", float(timeout + start - time.time()))
|
|
225
|
-
logger.trace("Frame timeout: {}"
|
|
247
|
+
logger.trace(f"Frame timeout: {timeout}")
|
|
248
|
+
|
|
226
249
|
if err:
|
|
227
250
|
raise err
|
|
228
|
-
|
|
251
|
+
|
|
252
|
+
return all_elements if continue_search else web_element
|
|
253
|
+
|
|
229
254
|
driver.switch_to.default_content()
|
|
230
255
|
raise QWebTimeoutError("From frame decorator: Unable to locate element in given time")
|
|
231
256
|
|
|
232
|
-
# pylint: disable=W0102
|
|
257
|
+
# pylint: disable=W0102, too-many-branches
|
|
233
258
|
def search_from_frames_safari(
|
|
234
259
|
driver: Optional[WebDriver] = None,
|
|
235
260
|
current_frame: Union[Optional[WebElement], int] = None,
|
|
236
261
|
parent_tree: list[Union[WebElement, int]] = [],
|
|
237
|
-
):
|
|
262
|
+
) -> Callable[..., Any]:
|
|
263
|
+
# Initialize the list to store found elements if continue_search is True
|
|
264
|
+
all_elements = []
|
|
238
265
|
keep_frame = kwargs.get("stay_in_current_frame", CONFIG["StayInCurrentFrame"])
|
|
239
266
|
if keep_frame:
|
|
240
267
|
return fn(*args, **kwargs)
|
|
268
|
+
|
|
241
269
|
err = None
|
|
242
270
|
if not driver:
|
|
243
271
|
driver = browser.get_current_browser()
|
|
244
272
|
driver.switch_to.default_content()
|
|
273
|
+
|
|
245
274
|
if current_frame is not None:
|
|
246
275
|
try:
|
|
247
276
|
driver.switch_to.frame(current_frame)
|
|
248
|
-
logger.debug("
|
|
277
|
+
logger.debug("Switching to child frame {}".format(str(fn)))
|
|
249
278
|
except (StaleElementReferenceException, WebDriverException) as e:
|
|
250
279
|
logger.debug(str(e))
|
|
251
280
|
driver.switch_to.default_content()
|
|
252
281
|
raise e
|
|
282
|
+
|
|
253
283
|
try:
|
|
254
284
|
web_element = fn(*args, **kwargs)
|
|
255
285
|
except QWebElementNotFoundError as e:
|
|
256
286
|
err = e
|
|
257
287
|
web_element = None
|
|
288
|
+
|
|
258
289
|
if is_valid(web_element):
|
|
259
|
-
|
|
290
|
+
if not continue_search:
|
|
291
|
+
return web_element
|
|
292
|
+
|
|
293
|
+
if not isinstance(web_element, tuple):
|
|
294
|
+
web_element = list(web_element)
|
|
295
|
+
all_elements.extend(web_element) # Accumulate elements if continuing search
|
|
296
|
+
|
|
260
297
|
start = time.time()
|
|
261
298
|
timeout = CONFIG["FrameTimeout"]
|
|
262
299
|
while time.time() < timeout + start:
|
|
263
300
|
frames = fc.check_frames(driver)
|
|
264
301
|
for count, frame in enumerate(frames): # pylint: disable=W0612
|
|
265
302
|
parent_tree.append(count)
|
|
266
|
-
# using count instead of frame reference due to Safari bug
|
|
267
303
|
web_element = search_from_frames_safari(
|
|
268
304
|
driver=driver, current_frame=count, parent_tree=parent_tree
|
|
269
305
|
)
|
|
270
306
|
if is_valid(web_element):
|
|
271
|
-
logger.debug("Found
|
|
272
|
-
|
|
307
|
+
logger.debug("Found web element = {}".format(web_element))
|
|
308
|
+
if not continue_search:
|
|
309
|
+
return web_element
|
|
310
|
+
if not isinstance(web_element, tuple):
|
|
311
|
+
web_element = list(web_element)
|
|
312
|
+
all_elements.extend(web_element) # Accumulate elements if continuing search
|
|
313
|
+
|
|
273
314
|
try:
|
|
274
|
-
# switch_to.parent_frame not working in Safari
|
|
275
|
-
# doing moving to previuos frame "manually"
|
|
276
315
|
parent_tree.pop()
|
|
277
316
|
driver.switch_to.default_content()
|
|
278
317
|
for f in parent_tree:
|
|
@@ -280,15 +319,21 @@ def all_frames(fn: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
280
319
|
except WebDriverException as e:
|
|
281
320
|
driver.switch_to.default_content()
|
|
282
321
|
raise e
|
|
322
|
+
|
|
283
323
|
config.set_config("FrameTimeout", float(timeout + start - time.time()))
|
|
284
324
|
logger.trace("Frame timeout: {}".format(timeout))
|
|
325
|
+
|
|
285
326
|
if err:
|
|
286
327
|
raise err
|
|
287
|
-
|
|
328
|
+
|
|
329
|
+
return all_elements if continue_search else web_element
|
|
330
|
+
|
|
288
331
|
driver.switch_to.default_content()
|
|
289
332
|
raise QWebTimeoutError("From frame decorator: Unable to locate element in given time")
|
|
290
333
|
|
|
291
|
-
|
|
334
|
+
if util.is_safari():
|
|
335
|
+
return search_from_frames_safari()
|
|
336
|
+
return search_from_frames()
|
|
292
337
|
|
|
293
338
|
logger.debug("wrapped = {}".format(wrapped))
|
|
294
339
|
return wrapped
|
|
@@ -123,6 +123,11 @@ def open_browser(url: str, browser_alias: str, options: Optional[str] = None, **
|
|
|
123
123
|
OpenBrowser http://google.com chrome emulation=iPhone SE
|
|
124
124
|
OpenBrowser http://google.com chrome emulation=375x812
|
|
125
125
|
|
|
126
|
+
# Selenium Grid usage
|
|
127
|
+
OpenBrowser http://google.com chrome remote_url=http://127.0.0.1:4444/wd/hub
|
|
128
|
+
OpenBrowser http://google.com safari remote_url=http://127.0.0.1:4444/wd/hub
|
|
129
|
+
CloseAllBrowsers
|
|
130
|
+
|
|
126
131
|
Selenium Manager
|
|
127
132
|
----------------
|
|
128
133
|
|
|
@@ -288,6 +293,8 @@ def open_browser(url: str, browser_alias: str, options: Optional[str] = None, **
|
|
|
288
293
|
Existing device profile name (i.e. "iPhone SE", must exist)
|
|
289
294
|
OR device dimensions in format:
|
|
290
295
|
WIDTHxHEIGHT (i.e. 385x812)
|
|
296
|
+
remote_url:
|
|
297
|
+
URL of the Selenium Grid server.
|
|
291
298
|
|
|
292
299
|
Raises
|
|
293
300
|
------
|
|
@@ -120,6 +120,10 @@ def set_config(par: str, val: Any) -> Any:
|
|
|
120
120
|
+---------------------+-----------------------------------------+----------------+
|
|
121
121
|
| ShadowDOM_ | Extend element searches to shadow DOM. | False |
|
|
122
122
|
+---------------------+-----------------------------------------+----------------+
|
|
123
|
+
| StayInCurrentFrame_ | Only search from current frame, do not | False |
|
|
124
|
+
| | automatically find elements from all | |
|
|
125
|
+
| | frames. Useful with \`UseFrame\`. | |
|
|
126
|
+
+---------------------+-----------------------------------------+----------------+
|
|
123
127
|
| XHRTimeout_ | Maximum wait for page to be loaded | 30s |
|
|
124
128
|
+---------------------+-----------------------------------------+----------------+
|
|
125
129
|
| VerifyAppAccuracy_ | Threshold for needed similarity in | 0.9999 |
|
|
@@ -476,6 +480,8 @@ def set_config(par: str, val: Any) -> Any:
|
|
|
476
480
|
Use False only when there is need to use and move
|
|
477
481
|
between frames and page manually for some reason.
|
|
478
482
|
|
|
483
|
+
Related setting: StayInCurrentFrame_
|
|
484
|
+
|
|
479
485
|
|
|
480
486
|
Examples
|
|
481
487
|
^^^^^^^^
|
|
@@ -993,6 +999,32 @@ def set_config(par: str, val: Any) -> Any:
|
|
|
993
999
|
ClickText As is this
|
|
994
1000
|
SetConfig ShadowDOM False
|
|
995
1001
|
|
|
1002
|
+
|
|
1003
|
+
.. _stayincurrentframe:
|
|
1004
|
+
|
|
1005
|
+
----
|
|
1006
|
+
|
|
1007
|
+
Parameter: StayInCurrentFrame
|
|
1008
|
+
-----------------------------
|
|
1009
|
+
|
|
1010
|
+
Disables default automatic frame traverse when searching elements.
|
|
1011
|
+
|
|
1012
|
+
Use True only when there is need to use a specific frame and
|
|
1013
|
+
find elements from that specific frame only.
|
|
1014
|
+
|
|
1015
|
+
Default = False (Automatic frame traverse in on).
|
|
1016
|
+
|
|
1017
|
+
Related setting: DefaultDocument_
|
|
1018
|
+
|
|
1019
|
+
Examples
|
|
1020
|
+
^^^^^^^^
|
|
1021
|
+
.. code-block:: robotframework
|
|
1022
|
+
|
|
1023
|
+
UseFrame //iframe
|
|
1024
|
+
SetConfig StayInCurrentFrame True
|
|
1025
|
+
# Sets focus to first nested frame in current frame
|
|
1026
|
+
UseFrame //iframe
|
|
1027
|
+
|
|
996
1028
|
---
|
|
997
1029
|
|
|
998
1030
|
Related keywords
|
|
@@ -422,6 +422,7 @@ def get_webelement(
|
|
|
422
422
|
anchor: str = "1",
|
|
423
423
|
element_type: Optional[str] = None,
|
|
424
424
|
timeout: Union[int, float, str] = 0,
|
|
425
|
+
all_frames: bool = True,
|
|
425
426
|
**kwargs,
|
|
426
427
|
) -> Union[Select, Optional[WebElement], list[WebElement]]:
|
|
427
428
|
# pylint: disable=too-many-branches
|
|
@@ -437,6 +438,8 @@ def get_webelement(
|
|
|
437
438
|
${list of elems} GetWebelement click_me tag=button
|
|
438
439
|
${list of elems} GetWebelement //*[@id\="click_me"]
|
|
439
440
|
${list of elems} GetWebelement xpath\=//*[@id\="click_me"]
|
|
441
|
+
# return elements only from the first frame with matching elements
|
|
442
|
+
${list of elems} GetWebelement xpath\=//*[@id\="click_me"] all_frames=False
|
|
440
443
|
|
|
441
444
|
Get element using element_type attribute to locate element.
|
|
442
445
|
Text elements works as ClickText, VerifyText, GetText etc.:
|
|
@@ -475,6 +478,11 @@ def get_webelement(
|
|
|
475
478
|
element_type : string
|
|
476
479
|
Define element type/preferred searching method
|
|
477
480
|
(available types: text, input, checkbox, item, dropdown or css).
|
|
481
|
+
all_frames : bool
|
|
482
|
+
In cases where list is expected to be returned, traverse through all frames
|
|
483
|
+
(True) or stop on the first frame which contains matching elements (False).
|
|
484
|
+
Doesn't have any effect if there are no iframes or if element_type etc. are used.
|
|
485
|
+
Default=True.
|
|
478
486
|
timeout : int
|
|
479
487
|
How long we wait element to appear. Default=10 sec
|
|
480
488
|
kwargs :
|
|
@@ -491,6 +499,7 @@ def get_webelement(
|
|
|
491
499
|
elem_index = kwargs.get("index", None)
|
|
492
500
|
kwargs["index"] = kwargs.get("index", 1)
|
|
493
501
|
kwargs["timeout"] = timeout
|
|
502
|
+
kwargs["continue_search"] = all_frames
|
|
494
503
|
if element_type:
|
|
495
504
|
if element_type.lower() == "text":
|
|
496
505
|
web_elements = text.get_element_by_locator_text(locator, anchor, **kwargs)
|
|
@@ -611,7 +620,7 @@ def get_attribute(
|
|
|
611
620
|
----------------
|
|
612
621
|
\`VerifyAttribute\`, \`VerifyElement\`
|
|
613
622
|
"""
|
|
614
|
-
webelement = get_webelement(locator, anchor, element_type, timeout, **kwargs)
|
|
623
|
+
webelement = get_webelement(locator, anchor, element_type, timeout, all_frames=False, **kwargs)
|
|
615
624
|
|
|
616
625
|
if not webelement:
|
|
617
626
|
raise QWebElementNotFoundError(
|
|
@@ -33,6 +33,9 @@ from QWeb.internal import browser, element, frame, javascript
|
|
|
33
33
|
def use_frame(locator: str) -> None:
|
|
34
34
|
"""Make following keywords to use frame on a page.
|
|
35
35
|
|
|
36
|
+
Note: See SetConfig settings "DefaultDocument" and "StayInCurrentFrame", which
|
|
37
|
+
affect this keyword.
|
|
38
|
+
|
|
36
39
|
Examples
|
|
37
40
|
--------
|
|
38
41
|
.. code-block:: robotframework
|
|
@@ -280,6 +280,8 @@ def verify_text_count(
|
|
|
280
280
|
"""
|
|
281
281
|
expected_count = int(expected_count)
|
|
282
282
|
kwargs["css"] = False
|
|
283
|
+
# make frame search continue and not stop on first frame with matching items
|
|
284
|
+
kwargs["continue_search"] = True
|
|
283
285
|
try:
|
|
284
286
|
webelements = internal_text.get_all_text_elements(text, **kwargs)
|
|
285
287
|
element_count = len(webelements)
|
|
@@ -337,6 +339,8 @@ def get_text_count(text: str, timeout: Union[int, float, str] = 0, **kwargs) ->
|
|
|
337
339
|
\`GetElementCount\`, \`VerifyTextCount\`
|
|
338
340
|
"""
|
|
339
341
|
kwargs["css"] = False
|
|
342
|
+
# make frame search continue and not stop on first frame with matching items
|
|
343
|
+
kwargs["continue_search"] = True
|
|
340
344
|
web_elements = internal_text.get_all_text_elements(text, **kwargs)
|
|
341
345
|
return len(web_elements)
|
|
342
346
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: QWeb
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Keyword driven automation for the web
|
|
5
5
|
Home-page: https://github.com/qentinelqi/qweb/
|
|
6
|
-
Author:
|
|
7
|
-
Author-email:
|
|
6
|
+
Author: Copado Inc.
|
|
7
|
+
Author-email: copadorobotictesting@copado.com
|
|
8
8
|
License: Apache License 2.0
|
|
9
9
|
Keywords: test automation robot framework
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.8
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.9
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
15
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
16
|
Classifier: Framework :: Robot Framework
|
|
16
17
|
Classifier: Framework :: Robot Framework :: Library
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
setuptools>=
|
|
1
|
+
setuptools>=70.0.0
|
|
2
2
|
pyscreeze==0.1.28
|
|
3
3
|
pyautogui>=0.9.53
|
|
4
|
-
pynput>=1.7.
|
|
5
|
-
requests>=2.32.
|
|
4
|
+
pynput>=1.7.7
|
|
5
|
+
requests>=2.32.2
|
|
6
6
|
robotframework<8,>=4.1.3
|
|
7
|
-
robotframework-debuglibrary==2.
|
|
8
|
-
selenium<5,>=4.
|
|
7
|
+
robotframework-debuglibrary==2.5.0
|
|
8
|
+
selenium<5,>=4.16.0
|
|
9
9
|
Pillow<11,>=10.3.0
|
|
10
10
|
scipy>=1.7.3
|
|
11
|
-
scikit-image==0.21
|
|
12
11
|
ply
|
|
13
12
|
numpy<2,>=1.23.5
|
|
14
13
|
opencv-python==4.8.1.78
|
|
@@ -20,3 +19,9 @@ pyobjc>=9.2
|
|
|
20
19
|
|
|
21
20
|
[:"linux" in sys_platform]
|
|
22
21
|
xlib
|
|
22
|
+
|
|
23
|
+
[:python_version == "3.8"]
|
|
24
|
+
scikit-image==0.21
|
|
25
|
+
|
|
26
|
+
[:python_version > "3.8"]
|
|
27
|
+
scikit-image==0.24
|
|
@@ -34,27 +34,29 @@ setup(
|
|
|
34
34
|
'Programming Language :: Python :: 3.9',
|
|
35
35
|
'Programming Language :: Python :: 3.10',
|
|
36
36
|
'Programming Language :: Python :: 3.11',
|
|
37
|
+
'Programming Language :: Python :: 3.12',
|
|
37
38
|
'License :: OSI Approved :: Apache Software License',
|
|
38
39
|
'Framework :: Robot Framework',
|
|
39
40
|
'Framework :: Robot Framework :: Library'
|
|
40
41
|
],
|
|
41
42
|
|
|
42
43
|
keywords='test automation robot framework',
|
|
43
|
-
author='
|
|
44
|
-
author_email='
|
|
44
|
+
author='Copado Inc.',
|
|
45
|
+
author_email='copadorobotictesting@copado.com',
|
|
45
46
|
python_requires= ">3.7,<4.0",
|
|
46
47
|
license= "Apache License 2.0",
|
|
47
|
-
install_requires=["setuptools>=
|
|
48
|
+
install_requires=["setuptools>=70.0.0",
|
|
48
49
|
"pyscreeze==0.1.28",
|
|
49
50
|
"pyautogui>=0.9.53",
|
|
50
|
-
"pynput>=1.7.
|
|
51
|
-
'requests>=2.32.
|
|
51
|
+
"pynput>=1.7.7",
|
|
52
|
+
'requests>=2.32.2',
|
|
52
53
|
"robotframework>=4.1.3,<8",
|
|
53
|
-
"robotframework-debuglibrary==2.
|
|
54
|
-
"selenium>=4.
|
|
54
|
+
"robotframework-debuglibrary==2.5.0",
|
|
55
|
+
"selenium>=4.16.0,<5",
|
|
55
56
|
"Pillow>=10.3.0,<11",
|
|
56
57
|
"scipy>=1.7.3",
|
|
57
|
-
"scikit-image==0.21",
|
|
58
|
+
"scikit-image==0.21;python_version=='3.8'",
|
|
59
|
+
"scikit-image==0.24;python_version>'3.8'",
|
|
58
60
|
"ply",
|
|
59
61
|
"numpy>=1.23.5,<2",
|
|
60
62
|
"opencv-python==4.8.1.78",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
# Version: 0.18
|
|
2
|
+
# Version: 0.18 (modified for QWeb)
|
|
3
3
|
|
|
4
4
|
"""The Versioneer - like a rocketeer, but for versions.
|
|
5
5
|
|
|
@@ -339,15 +339,22 @@ def get_config_from_root(root):
|
|
|
339
339
|
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
|
|
340
340
|
# the top of versioneer.py for instructions on writing your setup.cfg .
|
|
341
341
|
setup_cfg = os.path.join(root, "setup.cfg")
|
|
342
|
-
|
|
342
|
+
try:
|
|
343
|
+
parser = configparser.SafeConfigParser()
|
|
344
|
+
except Exception:
|
|
345
|
+
parser = configparser.ConfigParser()
|
|
343
346
|
with open(setup_cfg, "r") as f:
|
|
344
|
-
|
|
347
|
+
try:
|
|
348
|
+
parser.readfp(f)
|
|
349
|
+
except Exception:
|
|
350
|
+
parser.read_file(f)
|
|
345
351
|
VCS = parser.get("versioneer", "VCS") # mandatory
|
|
346
352
|
|
|
347
353
|
def get(parser, name):
|
|
348
354
|
if parser.has_option("versioneer", name):
|
|
349
355
|
return parser.get("versioneer", name)
|
|
350
356
|
return None
|
|
357
|
+
|
|
351
358
|
cfg = VersioneerConfig()
|
|
352
359
|
cfg.VCS = VCS
|
|
353
360
|
cfg.style = get(parser, "style") or ""
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
import os
|
|
3
|
-
from typing import Optional, Any
|
|
4
|
-
from selenium.webdriver.remote.webdriver import WebDriver
|
|
5
|
-
from selenium.webdriver import Chrome
|
|
6
|
-
from selenium.webdriver.chrome.options import Options
|
|
7
|
-
from selenium.webdriver.chrome.service import Service
|
|
8
|
-
from robot.api import logger
|
|
9
|
-
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
|
|
10
|
-
from QWeb.internal import browser, user, util
|
|
11
|
-
from QWeb.internal.config_defaults import CONFIG
|
|
12
|
-
|
|
13
|
-
NAMES: list[str] = ["chrome", "gc"]
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def check_browser_reuse(**kwargs: Any) -> tuple[bool, Optional[str], Optional[str]]:
|
|
17
|
-
try:
|
|
18
|
-
browser_reuse = util.par2bool(util.get_rfw_variable_value("${BROWSER_REUSE}")) or False
|
|
19
|
-
dbg_addr = kwargs.get("debugger_address", None) or util.get_rfw_variable_value(
|
|
20
|
-
"${BROWSER_DEBUGGER_ADDRESS}"
|
|
21
|
-
)
|
|
22
|
-
executor_url = kwargs.get("executor_url", None) or util.get_rfw_variable_value(
|
|
23
|
-
"${BROWSER_EXECUTOR_URL}"
|
|
24
|
-
)
|
|
25
|
-
return browser_reuse, dbg_addr, executor_url
|
|
26
|
-
except RobotNotRunningError:
|
|
27
|
-
pass
|
|
28
|
-
|
|
29
|
-
return False, None, None
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def write_browser_session_argsfile(
|
|
33
|
-
dbg_addr: str, executor_url: str, fname: str = "browser_session.arg"
|
|
34
|
-
) -> str:
|
|
35
|
-
robot_output = util.get_rfw_variable_value("${OUTPUT DIR}")
|
|
36
|
-
args_fn = os.path.join(robot_output or os.getcwd(), fname)
|
|
37
|
-
with open(args_fn, "w") as args_file:
|
|
38
|
-
args_file.write(f"-v BROWSER_REUSE:{True}{os.linesep}")
|
|
39
|
-
args_file.write(f"-v BROWSER_DEBUGGER_ADDRESS:{dbg_addr}{os.linesep}")
|
|
40
|
-
args_file.write(f"-v BROWSER_EXECUTOR_URL:{executor_url}{os.linesep}")
|
|
41
|
-
|
|
42
|
-
return args_fn
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def open_browser(
|
|
46
|
-
executable_path: str = "", chrome_args: Optional[list[str]] = None, **kwargs: Any
|
|
47
|
-
) -> WebDriver:
|
|
48
|
-
"""Open Chrome browser instance and cache the driver.
|
|
49
|
-
|
|
50
|
-
Parameters
|
|
51
|
-
----------
|
|
52
|
-
executable_path : str (Default "chromedriver")
|
|
53
|
-
path to the executable. If the default is used it assumes the
|
|
54
|
-
executable is in the $PATH.
|
|
55
|
-
port : int (Default 0)
|
|
56
|
-
port you would like the service to run, if left as 0, a free port will
|
|
57
|
-
be found.
|
|
58
|
-
desired_capabilities : dict (Default None)
|
|
59
|
-
Dictionary object with non-browser specific capabilities only, such as
|
|
60
|
-
"proxy" or "loggingPref".
|
|
61
|
-
chrome_args : Optional arguments to modify browser settings
|
|
62
|
-
"""
|
|
63
|
-
options = Options()
|
|
64
|
-
|
|
65
|
-
logger.debug("opt: {}".format(options))
|
|
66
|
-
# Gets rid of Devtools listening .... printing
|
|
67
|
-
options.add_experimental_option("excludeSwitches", ["enable-logging"])
|
|
68
|
-
|
|
69
|
-
# If user wants to re-use existing browser session then
|
|
70
|
-
# he/she has to set variable BROWSER_REUSE_ENABLED to True.
|
|
71
|
-
# If enabled, then web driver connection details are written
|
|
72
|
-
# to an argument file. This file enables re-use of the current
|
|
73
|
-
# chrome session.
|
|
74
|
-
#
|
|
75
|
-
# When variables BROWSER_DEBUGGER_ADDRESS and BROWSER_EXECUTOR_URL are
|
|
76
|
-
# set from argument file, then OpenBrowser will use those
|
|
77
|
-
# parameters instead of opening new chrome session.
|
|
78
|
-
# New Remote Web Driver is created in headless mode.
|
|
79
|
-
chromedriver_path = util.get_rfw_variable_value("${CHROMEDRIVER_PATH}") or executable_path
|
|
80
|
-
chrome_path = kwargs.get("chrome_path", None) or util.get_rfw_variable_value("${CHROME_PATH}")
|
|
81
|
-
chrome_version_kwarg = kwargs.get("browser_version", None)
|
|
82
|
-
chrome_version = chrome_version_kwarg or util.get_rfw_variable_value("${BROWSER_VERSION}")
|
|
83
|
-
if chrome_path:
|
|
84
|
-
options.binary_location = chrome_path
|
|
85
|
-
if chrome_version:
|
|
86
|
-
options.browser_version = chrome_version
|
|
87
|
-
browser_reuse, debugger_address, executor_url = check_browser_reuse(**kwargs)
|
|
88
|
-
logger.debug(
|
|
89
|
-
f"browser_reuse: {browser_reuse}, "
|
|
90
|
-
f"executor_url: {executor_url}, "
|
|
91
|
-
f"debugger_address: {debugger_address}"
|
|
92
|
-
)
|
|
93
|
-
if browser_reuse and executor_url and debugger_address:
|
|
94
|
-
options_new = Options()
|
|
95
|
-
options_new.add_argument("headless")
|
|
96
|
-
options_new.debugger_address = debugger_address
|
|
97
|
-
service = Service()
|
|
98
|
-
driver = Chrome(service=service, options=options_new)
|
|
99
|
-
else:
|
|
100
|
-
if user.is_root():
|
|
101
|
-
options.add_argument("no-sandbox")
|
|
102
|
-
if chrome_args:
|
|
103
|
-
if any("headless" in _.lower() for _ in chrome_args):
|
|
104
|
-
CONFIG.set_value("Headless", True)
|
|
105
|
-
for item in chrome_args:
|
|
106
|
-
options.add_argument(item.lstrip())
|
|
107
|
-
options.add_argument("start-maximized")
|
|
108
|
-
options.add_argument("--disable-notifications")
|
|
109
|
-
if "headless" in kwargs:
|
|
110
|
-
CONFIG.set_value("Headless", True)
|
|
111
|
-
options.add_argument("headless")
|
|
112
|
-
if "prefs" in kwargs:
|
|
113
|
-
tmp_prefs = kwargs.get("prefs")
|
|
114
|
-
prefs = util.parse_prefs(tmp_prefs)
|
|
115
|
-
options.add_experimental_option("prefs", prefs)
|
|
116
|
-
if "emulation" in kwargs:
|
|
117
|
-
emulation = kwargs["emulation"]
|
|
118
|
-
emulate_device = util.get_emulation_pref(emulation)
|
|
119
|
-
options.add_experimental_option("mobileEmulation", emulate_device)
|
|
120
|
-
|
|
121
|
-
service = Service(chromedriver_path) if chromedriver_path else Service()
|
|
122
|
-
driver = Chrome(service=service, options=options)
|
|
123
|
-
|
|
124
|
-
browser_reuse_enabled = (
|
|
125
|
-
util.par2bool(util.get_rfw_variable_value("${BROWSER_REUSE_ENABLED}")) or False
|
|
126
|
-
)
|
|
127
|
-
if browser_reuse_enabled:
|
|
128
|
-
# Write WebDriver session info to RF arguments file for re-use
|
|
129
|
-
dbg_address = driver.capabilities["goog:chromeOptions"]["debuggerAddress"]
|
|
130
|
-
write_browser_session_argsfile(dbg_address, driver.command_executor._url) # type: ignore # pylint: disable=protected-access,line-too-long
|
|
131
|
-
|
|
132
|
-
# Clear possible existing global values
|
|
133
|
-
BuiltIn().set_global_variable("${BROWSER_EXECUTOR_URL}", None)
|
|
134
|
-
BuiltIn().set_global_variable("${BROWSER_DEBUGGER_ADDRESS}", None)
|
|
135
|
-
|
|
136
|
-
browser.cache_browser(driver)
|
|
137
|
-
return driver
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|