QWeb 3.4.2__tar.gz → 3.5.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.
Files changed (84) hide show
  1. {qweb-3.4.2 → qweb-3.5.0}/PKG-INFO +23 -4
  2. {qweb-3.4.2 → qweb-3.5.0}/QWeb/__init__.py +28 -27
  3. {qweb-3.4.2 → qweb-3.5.0}/QWeb/_version.py +3 -3
  4. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/actions.py +58 -16
  5. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/chrome.py +1 -1
  6. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/element.py +16 -12
  7. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/input_.py +5 -0
  8. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/screenshot.py +1 -1
  9. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/secrets.py +3 -8
  10. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/text.py +29 -1
  11. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/element.py +137 -1
  12. qweb-3.5.0/QWeb/keywords/mouse.py +340 -0
  13. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/text.py +15 -1
  14. {qweb-3.4.2 → qweb-3.5.0}/QWeb.egg-info/PKG-INFO +23 -4
  15. {qweb-3.4.2 → qweb-3.5.0}/QWeb.egg-info/SOURCES.txt +1 -0
  16. {qweb-3.4.2 → qweb-3.5.0}/QWeb.egg-info/requires.txt +2 -2
  17. {qweb-3.4.2 → qweb-3.5.0}/README.md +20 -1
  18. {qweb-3.4.2 → qweb-3.5.0}/setup.py +2 -2
  19. {qweb-3.4.2 → qweb-3.5.0}/LICENSE +0 -0
  20. {qweb-3.4.2 → qweb-3.5.0}/MANIFEST.in +0 -0
  21. {qweb-3.4.2 → qweb-3.5.0}/QWeb/__main__.py +0 -0
  22. {qweb-3.4.2 → qweb-3.5.0}/QWeb/custom_config.py +0 -0
  23. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/__init__.py +0 -0
  24. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/ajax.py +0 -0
  25. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/alert.py +0 -0
  26. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/blocks.py +0 -0
  27. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/__init__.py +0 -0
  28. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/android.py +0 -0
  29. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/bs_desktop.py +0 -0
  30. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/bs_mobile.py +0 -0
  31. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/edge.py +0 -0
  32. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/firefox.py +0 -0
  33. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/browser/safari.py +0 -0
  34. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/checkbox.py +0 -0
  35. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/config.py +0 -0
  36. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/config_defaults.py +0 -0
  37. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/cookies.py +0 -0
  38. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/decorators.py +0 -0
  39. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/download.py +0 -0
  40. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/dragdrop.py +0 -0
  41. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/dropdown.py +0 -0
  42. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/exceptions.py +0 -0
  43. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/file.py +0 -0
  44. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/frame.py +0 -0
  45. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/frame_checker.py +0 -0
  46. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/icon.py +0 -0
  47. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/input_handler.py +0 -0
  48. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/javascript.py +0 -0
  49. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/lists.py +0 -0
  50. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/meas.py +0 -0
  51. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/platform.py +0 -0
  52. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/search_strategy.py +0 -0
  53. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/table.py +0 -0
  54. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/user.py +0 -0
  55. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/util.py +0 -0
  56. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/window.py +0 -0
  57. {qweb-3.4.2 → qweb-3.5.0}/QWeb/internal/xhr.py +0 -0
  58. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/__init__.py +0 -0
  59. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/ajax.py +0 -0
  60. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/alert.py +0 -0
  61. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/blocks.py +0 -0
  62. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/browser.py +0 -0
  63. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/checkbox.py +0 -0
  64. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/config.py +0 -0
  65. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/cookies.py +0 -0
  66. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/debug.py +0 -0
  67. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/download.py +0 -0
  68. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/dragdrop.py +0 -0
  69. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/dropdown.py +0 -0
  70. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/file.py +0 -0
  71. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/frame.py +0 -0
  72. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/icon.py +0 -0
  73. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/input_.py +0 -0
  74. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/javascript.py +0 -0
  75. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/lists.py +0 -0
  76. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/screenshot.py +0 -0
  77. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/search_strategy.py +0 -0
  78. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/table.py +0 -0
  79. {qweb-3.4.2 → qweb-3.5.0}/QWeb/keywords/window.py +0 -0
  80. {qweb-3.4.2 → qweb-3.5.0}/QWeb.egg-info/dependency_links.txt +0 -0
  81. {qweb-3.4.2 → qweb-3.5.0}/QWeb.egg-info/not-zip-safe +0 -0
  82. {qweb-3.4.2 → qweb-3.5.0}/QWeb.egg-info/top_level.txt +0 -0
  83. {qweb-3.4.2 → qweb-3.5.0}/setup.cfg +0 -0
  84. {qweb-3.4.2 → qweb-3.5.0}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: QWeb
3
- Version: 3.4.2
3
+ Version: 3.5.0
4
4
  Summary: Keyword driven automation for the web
5
5
  Home-page: https://github.com/qentinelqi/qweb/
6
6
  Author: Copado Inc.
@@ -22,9 +22,9 @@ Requires-Dist: pyscreeze==0.1.28
22
22
  Requires-Dist: pyautogui>=0.9.53
23
23
  Requires-Dist: pynput>=1.7.7
24
24
  Requires-Dist: requests>=2.32.2
25
- Requires-Dist: robotframework<8,>=4.1.3
25
+ Requires-Dist: robotframework<8,>=5.0.1
26
26
  Requires-Dist: robotframework-debuglibrary==2.5.0
27
- Requires-Dist: selenium<5,>=4.16.0
27
+ Requires-Dist: selenium<5,>=4.27.0
28
28
  Requires-Dist: Pillow<11,>=10.3.0
29
29
  Requires-Dist: scipy>=1.7.3
30
30
  Requires-Dist: scikit-image==0.21; python_version == "3.8"
@@ -98,7 +98,7 @@ See [examples](#examples).
98
98
 
99
99
  ---
100
100
  ## Requirements
101
- Python **3.9-3.12** and Robot Framework 4.1.3 or above.
101
+ Python **3.9-3.12** and Robot Framework 5.0.1 or above.
102
102
 
103
103
  (Note that support on Macs with Apple based silicon (M1) requires MacOS version 12/Monterey or above or [custom installation](https://github.com/qentinelqi/qweb/blob/master/docs/qweb_mac_m1_installation.md).)
104
104
 
@@ -110,6 +110,22 @@ Python **3.9-3.12** and Robot Framework 4.1.3 or above.
110
110
  ```
111
111
 
112
112
  ### Linux/Mac
113
+
114
+ Some Linux distributions (Ubuntu) use snap to install browsers, which brings it's own problems with non-default binary,
115
+ user data-dir and/or profile location. We suggest installing the browser via terminal, for example:
116
+
117
+ ```bash
118
+ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
119
+ apt-get install -y ./google-chrome-stable_current_amd64.deb
120
+ ```
121
+
122
+ Make sure the following dependencies are installed:
123
+
124
+ ```bash
125
+ sudo apt-get install python3-tk python3-dev scrot
126
+ pip install python-xlib
127
+ ```
128
+
113
129
  ```bash
114
130
  python3 -m pip install -U pip
115
131
  python3 -m pip install QWeb
@@ -129,6 +145,9 @@ Examples in [OpenBrowser keyword documentation](https://qentinelqi.github.io/qwe
129
145
  ### Manual driver management
130
146
  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
147
 
148
+ NOTE: Manual driver management should only be used in exceptional cases. Letting Selenium Manager handle
149
+ drivers is the preferred, less error prone option.
150
+
132
151
 
133
152
  [Back To The Top](#qweb)
134
153
 
@@ -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
- from typing import Callable, Any
17
+ import time
18
18
  import traceback
19
19
  import types
20
- import time
21
-
22
20
  from functools import wraps
23
- from QWeb import custom_config
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
- input_,
35
- javascript,
36
- screenshot,
38
+ config,
39
+ cookies,
40
+ debug,
37
41
  download,
38
- table,
39
- search_strategy,
42
+ dragdrop,
40
43
  dropdown,
41
- cookies,
42
- config,
44
+ element,
45
+ file,
46
+ frame,
43
47
  icon,
44
- dragdrop,
48
+ input_,
49
+ javascript,
45
50
  lists,
46
- file,
47
- debug,
48
- ajax,
49
- blocks,
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.
@@ -329,6 +329,7 @@ class QWeb:
329
329
  debug,
330
330
  ajax,
331
331
  blocks,
332
+ mouse,
332
333
  ):
333
334
  for name in dir(module):
334
335
  if not name.startswith("_"):
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-10-23T13:39:11+0300",
11
+ "date": "2025-02-07T13:46:59+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "04bc5d6d0ee82296341ec880141c7574d5e8110e",
15
- "version": "v3.4.2"
14
+ "full-revisionid": "822d8bc4abfa218fbaa27ff7685cbf79ad0e852f",
15
+ "version": "v3.5.0"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -26,33 +26,36 @@ 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
+ MoveTargetOutOfBoundsException,
38
+ NoSuchElementException,
39
+ WebDriverException,
43
40
  )
41
+ from selenium.webdriver.common.action_chains import ActionChains
42
+ from selenium.webdriver.common.actions.action_builder import ActionBuilder
43
+ from selenium.webdriver.common.by import By
44
+ from selenium.webdriver.remote.webelement import WebElement
45
+ from selenium.webdriver.support.select import Select
46
+
47
+ from QWeb.internal import browser, checkbox, decorators, javascript, util
48
+ from QWeb.internal import text as internal_text
49
+ from QWeb.internal.config_defaults import CONFIG
44
50
  from QWeb.internal.exceptions import (
45
- QWebValueMismatchError,
46
- QWebValueError,
47
- QWebUnexpectedConditionError,
48
51
  QWebInvalidElementStateError,
49
- QWebTimeoutError,
50
52
  QWebTextNotFoundError,
53
+ QWebTimeoutError,
54
+ QWebUnexpectedConditionError,
55
+ QWebValueError,
56
+ QWebValueMismatchError,
51
57
  )
52
- from QWeb.internal import text as internal_text, util
53
- from QWeb.internal import javascript, decorators, checkbox, browser
54
58
  from QWeb.internal.input_handler import INPUT_HANDLER as input_handler
55
- from QWeb.internal.config_defaults import CONFIG
56
59
 
57
60
 
58
61
  @decorators.timeout_decorator_for_actions
@@ -133,6 +136,24 @@ def scroll(web_element: WebElement, timeout: int) -> None: # pylint: disable=un
133
136
  javascript.execute_javascript("arguments[0].scrollIntoView();", web_element)
134
137
 
135
138
 
139
+ def scroll_overlay_adjustment(overlay_offset: int = 0) -> None: # pylint: disable=unused-argument
140
+ previous_scroll = None
141
+ driver = browser.get_current_browser()
142
+ current_scroll = driver.execute_script("return window.pageYOffset;")
143
+
144
+ # Keep checking until the scroll position stops changing
145
+ # This was needed in firefox because the scroll position was not updated immediately
146
+ while previous_scroll != current_scroll:
147
+ previous_scroll = current_scroll
148
+ time.sleep(0.2) # Small delay to allow scrolling to stabilize
149
+ current_scroll = driver.execute_script("return window.pageYOffset;")
150
+
151
+ # scroll up by overlay offset
152
+ # negative offset -> down, positive offset -> up
153
+ scroll_amount = -overlay_offset if overlay_offset > 0 else abs(overlay_offset)
154
+ driver.execute_script(f"window.scrollBy(0, {scroll_amount})")
155
+
156
+
136
157
  @decorators.timeout_decorator_for_actions
137
158
  def execute_click_and_verify_condition(
138
159
  web_element: WebElement, text_appear: bool = True, **kwargs: Any
@@ -183,6 +204,27 @@ def right_click(element: WebElement) -> None:
183
204
  ac.context_click(element).perform()
184
205
 
185
206
 
207
+ def mouse_down(element: Optional[WebElement] = None) -> None:
208
+ driver = browser.get_current_browser()
209
+ ac = ActionChains(driver)
210
+ ac.click_and_hold(element)
211
+ ac.perform()
212
+
213
+
214
+ def mouse_up(element: Optional[WebElement] = None) -> None:
215
+ driver = browser.get_current_browser()
216
+ ac = ActionChains(driver)
217
+ ac.release(element)
218
+ ac.perform()
219
+
220
+
221
+ def mouse_move(x: float, y: float) -> None:
222
+ driver = browser.get_current_browser()
223
+ ab = ActionBuilder(driver)
224
+ ab.pointer_action.move_to_location(x, y)
225
+ ab.perform()
226
+
227
+
186
228
  def js_click(web_element: WebElement) -> None:
187
229
  javascript.execute_javascript("arguments[0].click()", web_element)
188
230
  logger.debug("Js click performed")
@@ -158,6 +158,6 @@ def cache_browser_session(driver: WebDriver) -> None:
158
158
  )
159
159
  if browser_reuse_enabled:
160
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
161
+ write_browser_session_argsfile(dbg_address, driver.service.service_url) # type: ignore
162
162
  BuiltIn().set_global_variable("${BROWSER_EXECUTOR_URL}", None)
163
163
  BuiltIn().set_global_variable("${BROWSER_DEBUGGER_ADDRESS}", None)
@@ -642,22 +642,26 @@ def get_elements_by_attributes(
642
642
  if "tag" in kwargs:
643
643
  css = str(kwargs.get("tag"))
644
644
  try:
645
- elements = javascript.get_all_elements(css)
646
- if any_element:
647
- return elements
648
- matches = javascript.get_by_attributes(
649
- elements,
650
- locator.replace("'", "\\'"), # type: ignore[union-attr]
651
- partial,
652
- )
645
+ xpath_search = css.startswith("xpath=") or css.startswith("//")
646
+ if not xpath_search:
647
+ elements = javascript.get_all_elements(css)
648
+ if any_element:
649
+ return elements
650
+ matches = javascript.get_by_attributes(
651
+ elements,
652
+ locator.replace("'", "\\'"), # type: ignore[union-attr]
653
+ partial,
654
+ )
655
+ else:
656
+ matches = {"full": [], "partial": []}
653
657
 
654
- # try with xpath if no matches
655
- # there have been few where css search doesn't work
656
- # this is supported only if tag argument is given
658
+ # try with xpath if no matches and tag is givenor if css contains xpath
659
+ # there have been few cases where css search doesn't work
657
660
  if len(matches.get("full", [])) == 0 and len(matches.get("partial", [])) == 0:
658
661
  try:
662
+ xpath = css if xpath_search else f"//{css}"
659
663
  driver = browser.get_current_browser()
660
- elements = driver.find_elements(By.XPATH, f"//{css}")
664
+ elements = driver.find_elements(By.XPATH, xpath)
661
665
 
662
666
  matches = javascript.get_by_attributes(
663
667
  elements,
@@ -184,6 +184,11 @@ def get_input_element_by_css_selector(
184
184
  logger.debug("locator was text")
185
185
  if "qweb_old" not in kwargs:
186
186
  full_matches, partial_matches = get_input_elements_by_css(locator, **kwargs)
187
+ # backup search via xpath. This is needed due to javascript search not reaching
188
+ # all inputs under pseudo elements
189
+ if not full_matches and not partial_matches:
190
+ xpath = CONFIG["AllInputElements"]
191
+ full_matches, partial_matches = element.get_elements_by_attributes(xpath, locator)
187
192
 
188
193
  if full_matches:
189
194
  full_matches = text.filter_by_modal_ancestor(full_matches)
@@ -313,7 +313,7 @@ def chromium_full_screenshot(driver: WebDriver, filepath: str) -> str:
313
313
  resource = f"/session/{driver.session_id}/chromium/send_command_and_get_result"
314
314
 
315
315
  # pylint:disable=W0212
316
- url = driver.command_executor._url + resource
316
+ url = driver.service.service_url + resource
317
317
  body = json.dumps({"cmd": cmd, "params": params})
318
318
  response = driver.command_executor._request("POST", url, body)
319
319
  return response.get("value")
@@ -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
- LOGGER.log_message = LOGGER.message
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
- if not LOGGER._started_keywords:
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))
@@ -361,7 +361,7 @@ def get_item_using_anchor(text: str, anchor: str, **kwargs) -> Optional[WebEleme
361
361
  '@tooltip="{0}" or @aria-label="{0}" or @data-icon="{0}"]'.format(text)
362
362
  )
363
363
  if CONFIG["CssSelectors"]:
364
- web_elements = _get_item_by_css(text, **kwargs)
364
+ web_elements = _get_item_by_css(text, **kwargs) or _get_item_by_xpath(text, **kwargs)
365
365
  else:
366
366
  web_elements = element.get_webelements(xpath, **kwargs)
367
367
  # extend search to Shadow DOM
@@ -417,6 +417,34 @@ def _get_item_by_css(text: str, **kwargs) -> Optional[list[WebElement]]:
417
417
  return None
418
418
 
419
419
 
420
+ def _get_item_by_xpath(text: str, **kwargs) -> Optional[list[WebElement]]:
421
+ """
422
+ Backup search for finding items by attribute via xpath.
423
+ Needed in cases where there a slots that can't be pierced through
424
+ with javascript.
425
+
426
+ Allows partial match. Anchor has to be number.
427
+ :param text: str
428
+ Attribute value of the element
429
+ :return:
430
+ webelement that containing attribute with given value
431
+ """
432
+ if "partial_match" not in kwargs:
433
+ kwargs["partial_match"] = True
434
+ xpath = (
435
+ "//a | //span | //img | //li | //h1 | //h2 | //h3 | //h4 | //h5 | //h6 | //div | //svg | "
436
+ "//p | //button | //input[not(@type='text') and not(@type='password') and "
437
+ "not(@type='email')]"
438
+ )
439
+ # get_elements_by_attributes already handles going through frames
440
+ kwargs["continue_search"] = False
441
+ full, partial = element.get_elements_by_attributes(xpath, text, **kwargs)
442
+ web_elements = element.get_visible_elements_from_elements(full + partial, **kwargs)
443
+ if web_elements:
444
+ return web_elements
445
+ return None
446
+
447
+
420
448
  def _get_anchor_with_inner_text(
421
449
  anchor_elements: list[WebElement], anchor: str, exact_match: bool = True
422
450
  ) -> Optional[WebElement]:
@@ -17,7 +17,7 @@
17
17
  """Keywords for general elements that are retrieved using XPaths."""
18
18
 
19
19
  from __future__ import annotations
20
- from typing import Union, Optional
20
+ from typing import Union, Optional, Dict
21
21
  from selenium.webdriver.remote.webelement import WebElement
22
22
  from selenium.webdriver.support.select import Select
23
23
 
@@ -761,3 +761,139 @@ def verify_attribute(
761
761
  element.operator_verify(attr_val, value, operator)
762
762
  except QWebValueError as e:
763
763
  raise e
764
+
765
+
766
+ @keyword(tags=["Getters"])
767
+ def get_coordinates(
768
+ locator: Union[WebElement, str],
769
+ anchor: str = "1",
770
+ element_type: Optional[str] = None,
771
+ overlay_offset: int = 0,
772
+ timeout: Union[int, float, str] = 0,
773
+ **kwargs,
774
+ ) -> Dict[str, float]:
775
+ # pylint: disable=too-many-branches
776
+ r"""Gets middle point location (x, y) of the first element matching locator.
777
+ If locator is an instance of WebElement, returns the middle point location of that element.
778
+
779
+ This keyword tries to scroll the element into view (top) and then calculates the middle point
780
+ location. If the page has a overlay / top bar that covers the element,
781
+ you can use **overlay_offset** to adjust the scroll amount (see examples).
782
+
783
+ Examples
784
+ --------
785
+ Using attributes or xpaths like with ClickElement etc. kw:s without specified
786
+ element_type:
787
+
788
+ .. code-block:: robotframework
789
+
790
+ &{coords}= GetCoordinates click_me tag=button
791
+ Click Coordinates ${coords.x} ${coords.y}
792
+
793
+ &{coords}= GetCoordinates //*[@id\="click_me"]
794
+ &{coords}= GetCoordinates xpath\=//*[@id\="click_me"]
795
+
796
+
797
+ Using element_type attribute to locate element.
798
+ Text elements works as ClickText, VerifyText, GetText etc.:
799
+
800
+ .. code-block:: robotframework
801
+
802
+ &{coords}= GetCoordinates Log In id login element_type=text
803
+ &{coords}= GetCoordinates Contact value abc element_type=text anchor=Name
804
+ &{coords}= GetCoordinates Contact name contact1 parent=div
805
+ Click Coordinates ${coords.x} ${coords.y}
806
+
807
+ Item, Input, Dropdown, Checkbox elements:
808
+
809
+ .. code-block:: robotframework
810
+
811
+ &{coords}= GetCoordinates Log In id login element_type=item
812
+ &{coords}= GetCoordinates Username placeholder username element_type=input
813
+ &{coords}= GetCoordinates Country value Finland element_type=dropdown
814
+ &{coords}= GetCoordinates Gender checked checked element_type=checkbox
815
+ Click Coordinates ${coords.x} ${coords.y}
816
+
817
+ Using previously fetched WebElement instance:
818
+
819
+ .. code-block:: robotframework
820
+
821
+ ${element}= GetWebElement Log In id login element_type=item
822
+ &{coords}= GetCoordinates ${element}
823
+ Click Coordinates ${coords.x} ${coords.y}
824
+
825
+ If a page has an overlay that covers the element, you can use overlay_offset
826
+ to adjust the scroll:
827
+
828
+ .. code-block:: robotframework
829
+
830
+ # This will scroll the element into view and adjust the scroll (up) by 50 pixels
831
+ &{pos}= GetCoordinates Log In id login element_type=item overlay_offset=50
832
+ Click Coordinates ${pos.x} ${pos.y}
833
+
834
+
835
+ Parameters
836
+ ----------
837
+ locator : str
838
+ Visible text, attribute value Xpath expression or WebElement.
839
+ See GetWebElement for more information.
840
+ anchor : int
841
+ Used when element_type is defined. Default=1 (first match)
842
+ element_type : string
843
+ Define element type/preferred searching method
844
+ (available types: text, input, checkbox, item, dropdown or css).
845
+ overlay_offset: int
846
+ A positive integer representing the offset to adjust the scroll position
847
+ if a top bar or overlay obscures the element.
848
+ Typically, this is the height of the top overlay. Default = 0.
849
+
850
+ timeout : int
851
+ How long we wait element to appear. Default=10 sec
852
+ kwargs :
853
+ | Accepted kwargs:
854
+ | Any available for picked searching method.
855
+ | See interacting with text, item, input etc. elements from
856
+ | documentation
857
+
858
+ Returns
859
+ -------
860
+ dict: A dictionary with the coordinates `{"x": float, "y": float}`.
861
+
862
+ Related keywords
863
+ ----------------
864
+ \`ClickElement\`, \`HoverElement\`, \`TypeText\`, \`ClickCoordinates\`
865
+ """
866
+ kwargs.pop("all_frames", None)
867
+ webelement: Union[WebElement, list[WebElement]]
868
+
869
+ if overlay_offset < 0:
870
+ raise QWebValueError(f"The overlay_offset cannot be negative ({overlay_offset}).")
871
+ # webelement given as a locator
872
+ if isinstance(locator, WebElement):
873
+ webelement = locator
874
+ else:
875
+ webelement = get_webelement(locator,
876
+ anchor,
877
+ element_type,
878
+ timeout,
879
+ all_frames=False,
880
+ **kwargs)
881
+
882
+ # return first matching element
883
+ webelement = webelement[0] if isinstance(webelement, list) else webelement
884
+
885
+ try:
886
+
887
+ # scroll element into view and adjust scroll if needed
888
+ scrolled_position = webelement.location_once_scrolled_into_view
889
+ actions.scroll_overlay_adjustment(overlay_offset)
890
+
891
+ except Exception as e:
892
+ raise QWebValueError(f"Could not scroll element {locator} into view. Error: {e}") from e
893
+
894
+ # Calculate the coordinates at the center of the element + overlay height
895
+ size = webelement.size
896
+ x = scrolled_position['x'] + size["width"] / 2
897
+ y = scrolled_position['y'] + overlay_offset + size["height"] / 2
898
+
899
+ return {"x": x, "y": y}