QWeb 3.4.3__tar.gz → 3.6.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.4.3 → qweb-3.6.0}/PKG-INFO +43 -11
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/__init__.py +30 -27
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/_version.py +3 -3
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/actions.py +77 -16
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/__init__.py +2 -2
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/file.py +10 -12
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/javascript.py +90 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/screenshot.py +3 -5
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/secrets.py +3 -8
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/table.py +30 -2
- qweb-3.6.0/QWeb/keywords/debug.py +138 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/element.py +137 -1
- qweb-3.6.0/QWeb/keywords/mouse.py +340 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/table.py +3 -12
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/text.py +15 -1
- {qweb-3.4.3 → qweb-3.6.0}/QWeb.egg-info/PKG-INFO +43 -11
- {qweb-3.4.3 → qweb-3.6.0}/QWeb.egg-info/SOURCES.txt +1 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb.egg-info/requires.txt +10 -9
- {qweb-3.4.3 → qweb-3.6.0}/README.md +20 -1
- {qweb-3.4.3 → qweb-3.6.0}/setup.py +8 -7
- qweb-3.4.3/QWeb/keywords/debug.py +0 -80
- {qweb-3.4.3 → qweb-3.6.0}/LICENSE +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/MANIFEST.in +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/__main__.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/custom_config.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/__init__.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/ajax.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/alert.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/blocks.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/android.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/bs_desktop.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/bs_mobile.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/chrome.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/edge.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/firefox.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/browser/safari.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/checkbox.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/config.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/config_defaults.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/cookies.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/decorators.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/download.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/dragdrop.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/dropdown.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/element.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/exceptions.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/frame.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/frame_checker.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/icon.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/input_.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/input_handler.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/lists.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/meas.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/platform.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/search_strategy.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/text.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/user.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/util.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/window.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/internal/xhr.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/__init__.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/ajax.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/alert.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/blocks.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/browser.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/checkbox.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/config.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/cookies.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/download.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/dragdrop.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/dropdown.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/file.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/frame.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/icon.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/input_.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/javascript.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/lists.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/screenshot.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/search_strategy.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb/keywords/window.py +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb.egg-info/dependency_links.txt +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb.egg-info/not-zip-safe +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/QWeb.egg-info/top_level.txt +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/setup.cfg +0 -0
- {qweb-3.4.3 → qweb-3.6.0}/versioneer.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: QWeb
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.6.0
|
|
4
4
|
Summary: Keyword driven automation for the web
|
|
5
5
|
Home-page: https://github.com/qentinelqi/qweb/
|
|
6
6
|
Author: Copado Inc.
|
|
@@ -20,24 +20,37 @@ License-File: LICENSE
|
|
|
20
20
|
Requires-Dist: setuptools>=70.0.0
|
|
21
21
|
Requires-Dist: pyscreeze==0.1.28
|
|
22
22
|
Requires-Dist: pyautogui>=0.9.53
|
|
23
|
-
Requires-Dist: pynput>=1.
|
|
23
|
+
Requires-Dist: pynput>=1.8.0
|
|
24
|
+
Requires-Dist: pypdf>=5.4.0
|
|
25
|
+
Requires-Dist: pyperclip==1.9.0
|
|
24
26
|
Requires-Dist: requests>=2.32.2
|
|
25
27
|
Requires-Dist: robotframework<8,>=5.0.1
|
|
26
28
|
Requires-Dist: robotframework-debuglibrary==2.5.0
|
|
27
29
|
Requires-Dist: selenium<5,>=4.27.0
|
|
28
|
-
Requires-Dist: Pillow
|
|
30
|
+
Requires-Dist: Pillow>=11.0.0
|
|
29
31
|
Requires-Dist: scipy>=1.7.3
|
|
30
|
-
Requires-Dist: scikit-image==0.
|
|
31
|
-
Requires-Dist: scikit-image==0.
|
|
32
|
+
Requires-Dist: scikit-image==0.24; python_version == "3.9"
|
|
33
|
+
Requires-Dist: scikit-image==0.25.2; python_version > "3.9"
|
|
32
34
|
Requires-Dist: ply
|
|
33
|
-
Requires-Dist: numpy
|
|
34
|
-
Requires-Dist: opencv-python==4.
|
|
35
|
-
Requires-Dist: slate3k>=0.5.3
|
|
35
|
+
Requires-Dist: numpy>=2.0.0
|
|
36
|
+
Requires-Dist: opencv-python==4.11.0.86
|
|
36
37
|
Requires-Dist: xlib; "linux" in sys_platform
|
|
37
38
|
Requires-Dist: pyobjc-core>=9.2; "darwin" in sys_platform
|
|
38
39
|
Requires-Dist: pyobjc>=9.2; "darwin" in sys_platform
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
Dynamic: author
|
|
41
|
+
Dynamic: author-email
|
|
42
|
+
Dynamic: classifier
|
|
43
|
+
Dynamic: description
|
|
44
|
+
Dynamic: description-content-type
|
|
45
|
+
Dynamic: home-page
|
|
46
|
+
Dynamic: keywords
|
|
47
|
+
Dynamic: license
|
|
48
|
+
Dynamic: provides-extra
|
|
49
|
+
Dynamic: requires-dist
|
|
50
|
+
Dynamic: requires-python
|
|
51
|
+
Dynamic: summary
|
|
52
|
+
|
|
53
|
+
<img id="qweb" src="./images/qweb_logo_256.png" alt="QWeb">
|
|
41
54
|
|
|
42
55
|
> Keyword based test automation for the web.
|
|
43
56
|
|
|
@@ -110,6 +123,22 @@ Python **3.9-3.12** and Robot Framework 5.0.1 or above.
|
|
|
110
123
|
```
|
|
111
124
|
|
|
112
125
|
### Linux/Mac
|
|
126
|
+
|
|
127
|
+
Some Linux distributions (Ubuntu) use snap to install browsers, which brings it's own problems with non-default binary,
|
|
128
|
+
user data-dir and/or profile location. We suggest installing the browser via terminal, for example:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
132
|
+
apt-get install -y ./google-chrome-stable_current_amd64.deb
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Make sure the following dependencies are installed:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
sudo apt-get install python3-tk python3-dev scrot
|
|
139
|
+
pip install python-xlib
|
|
140
|
+
```
|
|
141
|
+
|
|
113
142
|
```bash
|
|
114
143
|
python3 -m pip install -U pip
|
|
115
144
|
python3 -m pip install QWeb
|
|
@@ -129,6 +158,9 @@ Examples in [OpenBrowser keyword documentation](https://qentinelqi.github.io/qwe
|
|
|
129
158
|
### Manual driver management
|
|
130
159
|
For manual installation of drivers, please refer to [Selenium documentation](https://www.selenium.dev/selenium/docs/api/py/index.html#drivers) for more information OR use 3rd party packages like [WebDriverManager](https://pypi.org/project/webdrivermanager/).
|
|
131
160
|
|
|
161
|
+
NOTE: Manual driver management should only be used in exceptional cases. Letting Selenium Manager handle
|
|
162
|
+
drivers is the preferred, less error prone option.
|
|
163
|
+
|
|
132
164
|
|
|
133
165
|
[Back To The Top](#qweb)
|
|
134
166
|
|
|
@@ -14,48 +14,48 @@
|
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
# ---------------------------
|
|
17
|
-
|
|
17
|
+
import time
|
|
18
18
|
import traceback
|
|
19
19
|
import types
|
|
20
|
-
import time
|
|
21
|
-
|
|
22
20
|
from functools import wraps
|
|
23
|
-
from
|
|
21
|
+
from typing import Any, Callable
|
|
24
22
|
|
|
25
23
|
try:
|
|
24
|
+
from robot.api import logger
|
|
25
|
+
from robot.libraries import Dialogs
|
|
26
|
+
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
|
|
27
|
+
from robot.utils import timestr_to_secs as _timestr_to_secs
|
|
28
|
+
|
|
29
|
+
from QWeb import custom_config
|
|
30
|
+
from QWeb.internal import util
|
|
31
|
+
from QWeb.internal.config_defaults import CONFIG
|
|
26
32
|
from QWeb.keywords import (
|
|
33
|
+
ajax,
|
|
27
34
|
alert,
|
|
35
|
+
blocks,
|
|
28
36
|
browser,
|
|
29
|
-
window,
|
|
30
|
-
frame,
|
|
31
|
-
element,
|
|
32
|
-
text,
|
|
33
37
|
checkbox,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
config,
|
|
39
|
+
cookies,
|
|
40
|
+
debug,
|
|
37
41
|
download,
|
|
38
|
-
|
|
39
|
-
search_strategy,
|
|
42
|
+
dragdrop,
|
|
40
43
|
dropdown,
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
element,
|
|
45
|
+
file,
|
|
46
|
+
frame,
|
|
43
47
|
icon,
|
|
44
|
-
|
|
48
|
+
input_,
|
|
49
|
+
javascript,
|
|
45
50
|
lists,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
mouse,
|
|
52
|
+
screenshot,
|
|
53
|
+
search_strategy,
|
|
54
|
+
table,
|
|
55
|
+
text,
|
|
56
|
+
window,
|
|
50
57
|
)
|
|
51
58
|
|
|
52
|
-
from QWeb.internal import util
|
|
53
|
-
from QWeb.internal.config_defaults import CONFIG
|
|
54
|
-
from robot.api import logger
|
|
55
|
-
from robot.utils import timestr_to_secs as _timestr_to_secs
|
|
56
|
-
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
|
|
57
|
-
from robot.libraries import Dialogs
|
|
58
|
-
|
|
59
59
|
# Print system exit message. This can happen on fresh linux when tkinter
|
|
60
60
|
# dependencies are not installed. This is a workaround as normally system
|
|
61
61
|
# exit message is not cathced by robot framework / debugger.
|
|
@@ -65,6 +65,8 @@ except SystemExit as se:
|
|
|
65
65
|
|
|
66
66
|
class QWeb:
|
|
67
67
|
r"""
|
|
68
|
+
.. image:: https://github.com/qentinelqi/qweb/raw/master/images/qweb_logo_256.png
|
|
69
|
+
|
|
68
70
|
QWeb is a powerful and versatile `Robot Framework <https://robotframework.org/>`_ library that
|
|
69
71
|
enables efficient and reliable web testing and automation. One of the key strengths of QWeb
|
|
70
72
|
is its intuitive and user-friendly syntax, which makes it easy to write and maintain complex
|
|
@@ -329,6 +331,7 @@ class QWeb:
|
|
|
329
331
|
debug,
|
|
330
332
|
ajax,
|
|
331
333
|
blocks,
|
|
334
|
+
mouse,
|
|
332
335
|
):
|
|
333
336
|
for name in dir(module):
|
|
334
337
|
if not name.startswith("_"):
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "
|
|
11
|
+
"date": "2025-04-15T12:02:40+0300",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "v3.
|
|
14
|
+
"full-revisionid": "6b5b2989c9b61213b51afbf7d1904dc0a107ffe2",
|
|
15
|
+
"version": "v3.6.0"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -26,33 +26,37 @@ Coding rules:
|
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
28
|
from __future__ import annotations
|
|
29
|
-
from typing import Optional, Union, Any
|
|
30
29
|
|
|
31
|
-
import time
|
|
32
30
|
import fnmatch
|
|
31
|
+
import time
|
|
32
|
+
from typing import Any, Optional, Union
|
|
33
|
+
|
|
33
34
|
from robot.api import logger
|
|
34
|
-
from selenium.webdriver.common.by import By
|
|
35
|
-
from selenium.webdriver.remote.webelement import WebElement
|
|
36
|
-
from selenium.webdriver.support.select import Select
|
|
37
|
-
from selenium.webdriver.common.action_chains import ActionChains
|
|
38
35
|
from selenium.common.exceptions import (
|
|
39
|
-
WebDriverException,
|
|
40
|
-
NoSuchElementException,
|
|
41
|
-
MoveTargetOutOfBoundsException,
|
|
42
36
|
ElementNotInteractableException,
|
|
37
|
+
JavascriptException,
|
|
38
|
+
MoveTargetOutOfBoundsException,
|
|
39
|
+
NoSuchElementException,
|
|
40
|
+
WebDriverException,
|
|
43
41
|
)
|
|
42
|
+
from selenium.webdriver.common.action_chains import ActionChains
|
|
43
|
+
from selenium.webdriver.common.actions.action_builder import ActionBuilder
|
|
44
|
+
from selenium.webdriver.common.by import By
|
|
45
|
+
from selenium.webdriver.remote.webelement import WebElement
|
|
46
|
+
from selenium.webdriver.support.select import Select
|
|
47
|
+
|
|
48
|
+
from QWeb.internal import browser, checkbox, decorators, javascript, util
|
|
49
|
+
from QWeb.internal import text as internal_text
|
|
50
|
+
from QWeb.internal.config_defaults import CONFIG
|
|
44
51
|
from QWeb.internal.exceptions import (
|
|
45
|
-
QWebValueMismatchError,
|
|
46
|
-
QWebValueError,
|
|
47
|
-
QWebUnexpectedConditionError,
|
|
48
52
|
QWebInvalidElementStateError,
|
|
49
|
-
QWebTimeoutError,
|
|
50
53
|
QWebTextNotFoundError,
|
|
54
|
+
QWebTimeoutError,
|
|
55
|
+
QWebUnexpectedConditionError,
|
|
56
|
+
QWebValueError,
|
|
57
|
+
QWebValueMismatchError,
|
|
51
58
|
)
|
|
52
|
-
from QWeb.internal import text as internal_text, util
|
|
53
|
-
from QWeb.internal import javascript, decorators, checkbox, browser
|
|
54
59
|
from QWeb.internal.input_handler import INPUT_HANDLER as input_handler
|
|
55
|
-
from QWeb.internal.config_defaults import CONFIG
|
|
56
60
|
|
|
57
61
|
|
|
58
62
|
@decorators.timeout_decorator_for_actions
|
|
@@ -133,6 +137,42 @@ def scroll(web_element: WebElement, timeout: int) -> None: # pylint: disable=un
|
|
|
133
137
|
javascript.execute_javascript("arguments[0].scrollIntoView();", web_element)
|
|
134
138
|
|
|
135
139
|
|
|
140
|
+
def scroll_overlay_adjustment(overlay_offset: int = 0) -> None: # pylint: disable=unused-argument
|
|
141
|
+
previous_scroll = -1
|
|
142
|
+
driver = browser.get_current_browser()
|
|
143
|
+
current_scroll = driver.execute_script("return window.pageYOffset;")
|
|
144
|
+
|
|
145
|
+
# Keep checking until the scroll position stops changing
|
|
146
|
+
# This was needed in firefox because the scroll position was not updated immediately
|
|
147
|
+
while previous_scroll != current_scroll:
|
|
148
|
+
previous_scroll = current_scroll
|
|
149
|
+
time.sleep(0.2) # Small delay to allow scrolling to stabilize
|
|
150
|
+
current_scroll = driver.execute_script("return window.pageYOffset;")
|
|
151
|
+
|
|
152
|
+
# scroll up by overlay offset
|
|
153
|
+
# negative offset -> down, positive offset -> up
|
|
154
|
+
scroll_amount = -overlay_offset if overlay_offset > 0 else abs(overlay_offset)
|
|
155
|
+
if driver.capabilities["browserName"].lower() in browser.firefox.NAMES:
|
|
156
|
+
# Firefox 135+ needs these settings in some Windows environments
|
|
157
|
+
# read current values
|
|
158
|
+
opt_wc = driver.execute_script("return getComputedStyle(document.body).willChange;")
|
|
159
|
+
opt_oa = driver.execute_script("return getComputedStyle(document.body).overflowAnchor;")
|
|
160
|
+
try:
|
|
161
|
+
# set new values and scroll
|
|
162
|
+
driver.execute_script("document.body.style.willChange = 'scroll-position';")
|
|
163
|
+
driver.execute_script("document.body.style.overflowAnchor = 'none';")
|
|
164
|
+
driver.execute_script(f"window.scrollBy(0, {scroll_amount})")
|
|
165
|
+
except JavascriptException:
|
|
166
|
+
pass
|
|
167
|
+
finally:
|
|
168
|
+
# Restore default behavior (to prevent unexpected side effects)
|
|
169
|
+
driver.execute_script(f"document.body.style.willChange = '{opt_wc}';")
|
|
170
|
+
driver.execute_script(f"document.body.style.overflowAnchor = '{opt_oa}';")
|
|
171
|
+
|
|
172
|
+
else:
|
|
173
|
+
driver.execute_script(f"window.scrollBy(0, {scroll_amount})")
|
|
174
|
+
|
|
175
|
+
|
|
136
176
|
@decorators.timeout_decorator_for_actions
|
|
137
177
|
def execute_click_and_verify_condition(
|
|
138
178
|
web_element: WebElement, text_appear: bool = True, **kwargs: Any
|
|
@@ -183,6 +223,27 @@ def right_click(element: WebElement) -> None:
|
|
|
183
223
|
ac.context_click(element).perform()
|
|
184
224
|
|
|
185
225
|
|
|
226
|
+
def mouse_down(element: Optional[WebElement] = None) -> None:
|
|
227
|
+
driver = browser.get_current_browser()
|
|
228
|
+
ac = ActionChains(driver)
|
|
229
|
+
ac.click_and_hold(element)
|
|
230
|
+
ac.perform()
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def mouse_up(element: Optional[WebElement] = None) -> None:
|
|
234
|
+
driver = browser.get_current_browser()
|
|
235
|
+
ac = ActionChains(driver)
|
|
236
|
+
ac.release(element)
|
|
237
|
+
ac.perform()
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def mouse_move(x: float, y: float) -> None:
|
|
241
|
+
driver = browser.get_current_browser()
|
|
242
|
+
ab = ActionBuilder(driver)
|
|
243
|
+
ab.pointer_action.move_to_location(x, y)
|
|
244
|
+
ab.perform()
|
|
245
|
+
|
|
246
|
+
|
|
186
247
|
def js_click(web_element: WebElement) -> None:
|
|
187
248
|
javascript.execute_javascript("arguments[0].click()", web_element)
|
|
188
249
|
logger.debug("Js click performed")
|
|
@@ -124,7 +124,7 @@ def cache_browser(driver: WebDriver) -> None:
|
|
|
124
124
|
# pylint: disable=global-statement
|
|
125
125
|
global _current_browser
|
|
126
126
|
# pylint: disable=global-statement, global-variable-not-assigned
|
|
127
|
-
global _open_browsers
|
|
127
|
+
global _open_browsers # noqa: F824
|
|
128
128
|
_current_browser = driver
|
|
129
129
|
_open_browsers.append(driver)
|
|
130
130
|
|
|
@@ -135,7 +135,7 @@ def remove_from_browser_cache(driver: WebDriver) -> None:
|
|
|
135
135
|
# pylint: disable=global-statement
|
|
136
136
|
global _current_browser
|
|
137
137
|
# pylint: disable=global-statement, global-variable-not-assigned
|
|
138
|
-
global _open_browsers
|
|
138
|
+
global _open_browsers # noqa: F824
|
|
139
139
|
_open_browsers.remove(driver)
|
|
140
140
|
# there's at least one browser open, move to latest
|
|
141
141
|
_current_browser = _open_browsers[-1] if _open_browsers else None
|
|
@@ -18,8 +18,8 @@ from __future__ import annotations
|
|
|
18
18
|
from typing import Any, Union
|
|
19
19
|
from pathlib import Path
|
|
20
20
|
import os
|
|
21
|
-
|
|
22
|
-
from
|
|
21
|
+
from pypdf import PdfReader
|
|
22
|
+
from pypdf.errors import PdfStreamError
|
|
23
23
|
from QWeb.internal import download, util
|
|
24
24
|
from QWeb.internal.exceptions import QWebFileNotFoundError, QWebValueMismatchError
|
|
25
25
|
|
|
@@ -36,17 +36,15 @@ class File:
|
|
|
36
36
|
def create_pdf_instance(filename: str) -> File:
|
|
37
37
|
all_text = ""
|
|
38
38
|
filepath = download.get_path(filename)
|
|
39
|
+
|
|
39
40
|
try:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
except TypeError as e:
|
|
48
|
-
raise QWebFileNotFoundError(f"File not found. Got {e} instead.") from e
|
|
49
|
-
except PSEOF as e:
|
|
41
|
+
reader = PdfReader(filepath)
|
|
42
|
+
for page in reader.pages:
|
|
43
|
+
all_text += page.extract_text()
|
|
44
|
+
if all_text != "":
|
|
45
|
+
return File(all_text, filepath)
|
|
46
|
+
raise QWebValueMismatchError("Text not found. Seems that the pdf is empty.")
|
|
47
|
+
except PdfStreamError as e:
|
|
50
48
|
raise QWebFileNotFoundError(f"File found, but it's not valid pdf-file: {e}") from e
|
|
51
49
|
|
|
52
50
|
@staticmethod
|
|
@@ -614,3 +614,93 @@ def get_item_elements_from_shadow_dom(tag: str) -> list[WebElement]:
|
|
|
614
614
|
return(find_item_elements_from_shadow_dom(arguments[0], arguments[1]))"""
|
|
615
615
|
)
|
|
616
616
|
return execute_javascript(js, tag)
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
def create_toast_notification(message: str, level: str = "info", position: str = "center",
|
|
620
|
+
font_size: int = 18,
|
|
621
|
+
heading: str = "Test Automation Notification", timeout: int = 3):
|
|
622
|
+
|
|
623
|
+
"""Display toast notification in the browser via JavaScript."""
|
|
624
|
+
js = f"""
|
|
625
|
+
var host = document.createElement('div');
|
|
626
|
+
host.style.position = 'fixed';
|
|
627
|
+
host.style.top = '0';
|
|
628
|
+
host.style.left = '0';
|
|
629
|
+
host.style.width = '100%';
|
|
630
|
+
host.style.height = '100%';
|
|
631
|
+
host.style.pointerEvents = 'none';
|
|
632
|
+
document.body.appendChild(host);
|
|
633
|
+
|
|
634
|
+
var shadow = host.attachShadow({{ mode: 'open' }});
|
|
635
|
+
|
|
636
|
+
var style = document.createElement('style');
|
|
637
|
+
style.textContent = `
|
|
638
|
+
* {{
|
|
639
|
+
box-sizing: border-box;
|
|
640
|
+
font-family: sans-serif, system-ui, Arial, Helvetica;
|
|
641
|
+
color: white;
|
|
642
|
+
}}
|
|
643
|
+
`;
|
|
644
|
+
shadow.appendChild(style);
|
|
645
|
+
|
|
646
|
+
var toast = document.createElement('div');
|
|
647
|
+
var iconText = '';
|
|
648
|
+
var bgColor = 'black';
|
|
649
|
+
|
|
650
|
+
if ('{level}' === 'success') {{ iconText = '✔️'; bgColor = 'green'; }}
|
|
651
|
+
else if ('{level}' === 'warning') {{ iconText = '⚠️'; bgColor = 'orange'; }}
|
|
652
|
+
else if ('{level}' === 'error') {{ iconText = '✖'; bgColor = 'red'; }}
|
|
653
|
+
else {{ iconText = 'ℹ️'; bgColor = 'black'; }}
|
|
654
|
+
|
|
655
|
+
toast.style.position = 'fixed';
|
|
656
|
+
toast.style.padding = '20px';
|
|
657
|
+
toast.style.borderRadius = '10px';
|
|
658
|
+
toast.style.zIndex = '10000';
|
|
659
|
+
toast.style.fontSize = '{font_size}px';
|
|
660
|
+
toast.style.boxShadow = '0 4px 12px rgba(0, 0, 0, 0.4)';
|
|
661
|
+
toast.style.border = '2px solid white';
|
|
662
|
+
toast.style.opacity = '0';
|
|
663
|
+
toast.style.background = bgColor;
|
|
664
|
+
toast.style.transition = 'opacity 0.5s ease';
|
|
665
|
+
toast.style.display = 'flex';
|
|
666
|
+
toast.style.flexDirection = 'column';
|
|
667
|
+
toast.style.alignItems = 'flex-start';
|
|
668
|
+
toast.style.gap = '8px';
|
|
669
|
+
|
|
670
|
+
if ('{position}' === 'top-left') {{ toast.style.top = '20px'; toast.style.left = '20px'; }}
|
|
671
|
+
else if ('{position}' === 'top-right') {{ toast.style.top = '20px'; toast.style.right = '20px'; }}
|
|
672
|
+
else if ('{position}' === 'bottom-left') {{ toast.style.bottom = '20px'; toast.style.left = '20px'; }}
|
|
673
|
+
else if ('{position}' === 'bottom-right') {{ toast.style.bottom = '20px'; toast.style.right = '20px'; }}
|
|
674
|
+
else {{ toast.style.top = '50%'; toast.style.left = '50%'; toast.style.transform = 'translate(-50%, -50%)'; }}
|
|
675
|
+
|
|
676
|
+
var headingElem = document.createElement('div');
|
|
677
|
+
headingElem.style.display = 'flex';
|
|
678
|
+
headingElem.style.alignItems = 'center';
|
|
679
|
+
headingElem.style.fontSize = '13px';
|
|
680
|
+
headingElem.style.fontWeight = 'bold';
|
|
681
|
+
headingElem.style.marginBottom = '4px';
|
|
682
|
+
|
|
683
|
+
var headingIcon = document.createElement('span');
|
|
684
|
+
headingIcon.textContent = iconText;
|
|
685
|
+
headingIcon.style.fontSize = '16px';
|
|
686
|
+
headingIcon.style.marginRight = '5px';
|
|
687
|
+
|
|
688
|
+
headingElem.appendChild(headingIcon);
|
|
689
|
+
headingElem.appendChild(document.createTextNode('{heading}'));
|
|
690
|
+
toast.appendChild(headingElem);
|
|
691
|
+
|
|
692
|
+
var text = document.createElement('div');
|
|
693
|
+
text.textContent = '{message}';
|
|
694
|
+
toast.appendChild(text);
|
|
695
|
+
|
|
696
|
+
shadow.appendChild(toast);
|
|
697
|
+
|
|
698
|
+
void toast.offsetHeight;
|
|
699
|
+
toast.style.opacity = '1';
|
|
700
|
+
|
|
701
|
+
setTimeout(function() {{
|
|
702
|
+
toast.style.opacity = '0';
|
|
703
|
+
setTimeout(function() {{ host.remove(); }}, 500);
|
|
704
|
+
}}, {timeout} * 1000);
|
|
705
|
+
"""
|
|
706
|
+
return execute_javascript(js)
|
|
@@ -141,12 +141,10 @@ def _draw_contours(diff: ndarray, ref_image_c: ndarray) -> ndarray:
|
|
|
141
141
|
"""
|
|
142
142
|
diff = (diff * 255).astype("uint8")
|
|
143
143
|
thresh = cv2.threshold(diff, 220, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
|
|
144
|
-
|
|
144
|
+
# Modified as per latest minimum required opencv version
|
|
145
|
+
contours, _ = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
index = 1 if cv2.__version__.startswith("3") else 0 # type: ignore
|
|
148
|
-
|
|
149
|
-
for c in contours[index]:
|
|
147
|
+
for c in contours:
|
|
150
148
|
(x, y, w, h) = cv2.boundingRect(c)
|
|
151
149
|
cv2.rectangle(ref_image_c, (x, y), ((x + w), (y + h)), (0, 0, 255), 2)
|
|
152
150
|
return ref_image_c
|
|
@@ -94,7 +94,6 @@ def _filtered_start_keyword(keyword: Keyword) -> None:
|
|
|
94
94
|
censored_args = _hide_keyword_arg_values(keyword)
|
|
95
95
|
_replace_keyword_args(keyword, tuple(censored_args))
|
|
96
96
|
|
|
97
|
-
LOGGER._started_keywords += 1
|
|
98
97
|
LOGGER.log_message = LOGGER._log_message
|
|
99
98
|
for start_logger in LOGGER.start_loggers:
|
|
100
99
|
start_logger.start_keyword(keyword)
|
|
@@ -127,7 +126,6 @@ def _filtered_start_library_keyword(data: Keyword, implementation: Keyword, resu
|
|
|
127
126
|
_replace_keyword_args(data, tuple(censored_args))
|
|
128
127
|
_replace_keyword_args(result, tuple(censored_args))
|
|
129
128
|
|
|
130
|
-
LOGGER._started_keywords += 1
|
|
131
129
|
LOGGER.log_message = LOGGER._log_message
|
|
132
130
|
for start_logger in LOGGER.start_loggers:
|
|
133
131
|
start_logger.start_library_keyword(data, implementation, result)
|
|
@@ -155,12 +153,11 @@ def _filtered_end_keyword(keyword: Keyword) -> None:
|
|
|
155
153
|
censored_args = _hide_keyword_arg_values(keyword)
|
|
156
154
|
_replace_keyword_args(keyword, tuple(censored_args))
|
|
157
155
|
|
|
158
|
-
LOGGER._started_keywords -= 1
|
|
159
156
|
for end_logger in LOGGER.end_loggers:
|
|
160
157
|
end_logger.end_keyword(keyword)
|
|
161
158
|
|
|
162
|
-
if not LOGGER._started_keywords:
|
|
163
|
-
|
|
159
|
+
# if not LOGGER._started_keywords:
|
|
160
|
+
LOGGER.log_message = LOGGER.message
|
|
164
161
|
|
|
165
162
|
if apply_filter:
|
|
166
163
|
_replace_keyword_args(keyword, tuple(original_args))
|
|
@@ -186,12 +183,10 @@ def _filtered_end_library_keyword(data: Keyword, implementation: Keyword, result
|
|
|
186
183
|
_replace_keyword_args(result, tuple(censored_args))
|
|
187
184
|
_replace_keyword_args(data, tuple(censored_args))
|
|
188
185
|
|
|
189
|
-
LOGGER._started_keywords -= 1
|
|
190
186
|
for end_logger in LOGGER.end_loggers:
|
|
191
187
|
end_logger.end_library_keyword(data, implementation, result)
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
LOGGER.log_message = LOGGER.message
|
|
189
|
+
LOGGER.log_message = LOGGER.message
|
|
195
190
|
|
|
196
191
|
if apply_filter:
|
|
197
192
|
_replace_keyword_args(result, tuple(original_args))
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
# ---------------------------
|
|
17
17
|
from __future__ import annotations
|
|
18
|
-
from typing import Optional, Union
|
|
18
|
+
from typing import List, Optional, Union
|
|
19
19
|
|
|
20
20
|
import fnmatch
|
|
21
21
|
import re
|
|
@@ -167,6 +167,7 @@ class Table:
|
|
|
167
167
|
row_elem = None
|
|
168
168
|
cell = None
|
|
169
169
|
locator = coordinates.split("/")
|
|
170
|
+
partial_match = util.par2bool(kwargs.get("partial_match", CONFIG["PartialMatch"]))
|
|
170
171
|
if locator[0].startswith("r?"):
|
|
171
172
|
row_elem = self.get_row(locator[0][2:], anchor)
|
|
172
173
|
# take last row as "row" if row_elem is not None
|
|
@@ -175,7 +176,13 @@ class Table:
|
|
|
175
176
|
else:
|
|
176
177
|
row, _ = self._convert_coordinates(locator[0])
|
|
177
178
|
if locator[1].startswith("c?"):
|
|
178
|
-
|
|
179
|
+
# try with old one if partial match used
|
|
180
|
+
if partial_match:
|
|
181
|
+
column = self.get_cell_by_locator(locator[1][2:], **kwargs)
|
|
182
|
+
else:
|
|
183
|
+
# new direct column index full match locator
|
|
184
|
+
column = self.get_full_match_column_index(locator[1][2:])
|
|
185
|
+
|
|
179
186
|
else:
|
|
180
187
|
_, column = self._convert_coordinates(f"r{row}{locator[1]}")
|
|
181
188
|
if row_elem:
|
|
@@ -386,3 +393,24 @@ class Table:
|
|
|
386
393
|
}
|
|
387
394
|
return(columns(arguments[0]));"""
|
|
388
395
|
return javascript.execute_javascript(js, self.table)
|
|
396
|
+
|
|
397
|
+
def get_full_match_column_index(self, locator: str) -> int:
|
|
398
|
+
"""Get the index of the column based on the locator text. Full match
|
|
399
|
+
is used to find the column header. Returned Index starts from 1.
|
|
400
|
+
"""
|
|
401
|
+
columns = self.get_columns()
|
|
402
|
+
column_texts = self.get_column_header_texts(columns)
|
|
403
|
+
try:
|
|
404
|
+
index = column_texts.index(locator)
|
|
405
|
+
index = index + 1
|
|
406
|
+
except ValueError as e:
|
|
407
|
+
raise QWebValueError(f"Matching column not found for locator {locator}.") from e
|
|
408
|
+
return index
|
|
409
|
+
|
|
410
|
+
def get_column_header_texts(self, columns: List[WebElement]) -> List[str]:
|
|
411
|
+
# prefer using aria-label, then title, then text
|
|
412
|
+
column_texts = [
|
|
413
|
+
c.get_attribute("aria-label") or c.get_attribute("title") or c.text for c in columns
|
|
414
|
+
]
|
|
415
|
+
|
|
416
|
+
return column_texts
|