QWeb 3.1.0__tar.gz → 3.2.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.1.0 → QWeb-3.2.0}/PKG-INFO +1 -1
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/_version.py +3 -3
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/actions.py +42 -32
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/config.py +7 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/element.py +22 -13
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/frame.py +1 -1
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/search_strategy.py +42 -17
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/table.py +26 -15
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/text.py +3 -2
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/browser.py +1 -1
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/config.py +38 -8
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/cookies.py +10 -3
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/element.py +6 -3
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/table.py +38 -10
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/text.py +24 -2
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb.egg-info/PKG-INFO +1 -1
- {QWeb-3.1.0 → QWeb-3.2.0}/LICENSE +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/MANIFEST.in +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/__init__.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/__main__.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/custom_config.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/__init__.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/ajax.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/alert.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/blocks.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/__init__.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/android.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/bs_desktop.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/bs_mobile.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/chrome.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/edge.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/firefox.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/browser/safari.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/checkbox.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/config_defaults.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/cookies.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/decorators.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/download.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/dragdrop.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/dropdown.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/exceptions.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/file.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/frame_checker.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/icon.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/input_.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/input_handler.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/javascript.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/lists.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/meas.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/platform.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/screenshot.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/secrets.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/user.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/util.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/window.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/internal/xhr.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/__init__.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/ajax.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/alert.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/blocks.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/checkbox.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/debug.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/download.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/dragdrop.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/dropdown.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/file.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/frame.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/icon.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/input_.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/javascript.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/lists.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/screenshot.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/search_strategy.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb/keywords/window.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb.egg-info/SOURCES.txt +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb.egg-info/dependency_links.txt +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb.egg-info/not-zip-safe +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb.egg-info/requires.txt +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/QWeb.egg-info/top_level.txt +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/README.md +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/setup.cfg +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/setup.py +0 -0
- {QWeb-3.1.0 → QWeb-3.2.0}/versioneer.py +0 -0
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2024-
|
|
11
|
+
"date": "2024-03-08T14:03:57+0200",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "v3.
|
|
14
|
+
"full-revisionid": "a1077ceb7dc7393d4a0a502db68bae57f5983409",
|
|
15
|
+
"version": "v3.2.0"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -74,7 +74,7 @@ def write(
|
|
|
74
74
|
logger.debug("Could not send line break key to input")
|
|
75
75
|
else:
|
|
76
76
|
input_handler.write(input_element, input_text, **kwargs)
|
|
77
|
-
logger.debug('Preferred text: "{}"'
|
|
77
|
+
logger.debug(f'Preferred text: "{input_text}"')
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
@decorators.timeout_decorator_for_actions
|
|
@@ -91,11 +91,12 @@ def compare_input_values(
|
|
|
91
91
|
expected_value = str(util.get_substring(expected_value, **kwargs))
|
|
92
92
|
except QWebValueError:
|
|
93
93
|
real_value = ""
|
|
94
|
-
logger.debug('Real value: {}, expected value {}'
|
|
94
|
+
logger.debug(f'Real value: {real_value}, expected value {expected_value}')
|
|
95
95
|
if fnmatch.fnmatch(str(real_value).strip(), expected_value):
|
|
96
96
|
return True
|
|
97
|
-
raise QWebValueMismatchError(
|
|
98
|
-
expected_value
|
|
97
|
+
raise QWebValueMismatchError(
|
|
98
|
+
f"""Expected value "{expected_value}" didn\'t match to real value "{real_value}\""""
|
|
99
|
+
)
|
|
99
100
|
|
|
100
101
|
|
|
101
102
|
@decorators.timeout_decorator_for_actions
|
|
@@ -111,7 +112,7 @@ def input_value(input_element: WebElement, timeout: int, **kwargs: Any) -> str:
|
|
|
111
112
|
return value.strip()
|
|
112
113
|
if blind:
|
|
113
114
|
return ''
|
|
114
|
-
raise QWebValueError('No Value found after {} sec'
|
|
115
|
+
raise QWebValueError(f'No Value found after {timeout} sec')
|
|
115
116
|
|
|
116
117
|
|
|
117
118
|
@decorators.timeout_decorator_for_actions
|
|
@@ -146,7 +147,7 @@ def execute_click_and_verify_condition(web_element: WebElement,
|
|
|
146
147
|
wd_click(web_element, **kwargs)
|
|
147
148
|
logger.debug('element clicked')
|
|
148
149
|
except WebDriverException as e:
|
|
149
|
-
logger.info('Got {} when tried to click.'
|
|
150
|
+
logger.info(f'Got {e} when tried to click.')
|
|
150
151
|
if 'text' not in kwargs:
|
|
151
152
|
raise e
|
|
152
153
|
if 'text' in kwargs:
|
|
@@ -287,8 +288,9 @@ def is_not_in_dropdown(select: Select, option: str, **kwargs: Any) -> bool:
|
|
|
287
288
|
""""Verifies that the selected option is not in the dropdown list"""
|
|
288
289
|
option_list = get_select_options(select, **kwargs)
|
|
289
290
|
if option in option_list:
|
|
290
|
-
raise QWebValueError(
|
|
291
|
-
option
|
|
291
|
+
raise QWebValueError(
|
|
292
|
+
f"Found the value {option} from the dropdown menu: {option_list}."
|
|
293
|
+
)
|
|
292
294
|
return True
|
|
293
295
|
|
|
294
296
|
|
|
@@ -314,8 +316,9 @@ def get_selected_value(
|
|
|
314
316
|
if expected:
|
|
315
317
|
if expected in selected:
|
|
316
318
|
return True
|
|
317
|
-
raise QWebValueMismatchError(
|
|
318
|
-
expected
|
|
319
|
+
raise QWebValueMismatchError(
|
|
320
|
+
f"""Expected value "{expected}" didn\'t match to real value "{txt_selected}"."""
|
|
321
|
+
)
|
|
319
322
|
return txt_selected
|
|
320
323
|
|
|
321
324
|
|
|
@@ -331,7 +334,7 @@ def get_select_options(
|
|
|
331
334
|
if fnmatch.fnmatch(expected, option.text):
|
|
332
335
|
return True
|
|
333
336
|
raise QWebValueMismatchError(
|
|
334
|
-
'Expected value "{}" not found from selectable options'
|
|
337
|
+
f'Expected value "{expected}" not found from selectable options')
|
|
335
338
|
# parse all options to a list and return it
|
|
336
339
|
option_list = []
|
|
337
340
|
for option in options:
|
|
@@ -390,7 +393,7 @@ def get_element_text(web_element: WebElement, expected=None, timeout: int = 0) -
|
|
|
390
393
|
try:
|
|
391
394
|
return _compare_texts(real_text, expected.strip(), timeout)
|
|
392
395
|
except QWebValueMismatchError as e:
|
|
393
|
-
raise QWebValueError('Expected {}, found {}'
|
|
396
|
+
raise QWebValueError(f'Expected {expected}, found {real_text}') from e
|
|
394
397
|
if real_text is not None:
|
|
395
398
|
return real_text
|
|
396
399
|
raise QWebValueMismatchError('Text not found')
|
|
@@ -398,7 +401,7 @@ def get_element_text(web_element: WebElement, expected=None, timeout: int = 0) -
|
|
|
398
401
|
|
|
399
402
|
def _compare_texts(text_to_compare: str, expected: str, timeout: int) -> bool: # pylint: disable=unused-argument
|
|
400
403
|
if fnmatch.fnmatch(text_to_compare, expected) is False:
|
|
401
|
-
raise QWebValueMismatchError('Expected {
|
|
404
|
+
raise QWebValueMismatchError(f'Expected {expected}, found {text_to_compare}')
|
|
402
405
|
return True
|
|
403
406
|
|
|
404
407
|
|
|
@@ -447,7 +450,7 @@ def scroll_first_scrollable_parent_element(locator: str, anchor: str, text_to_fi
|
|
|
447
450
|
return getScrollParent(arguments[0]);
|
|
448
451
|
"""
|
|
449
452
|
js_element_position = "return arguments[0].scrollTop;"
|
|
450
|
-
js_element_scroll = "arguments[0].scrollBy(0, {
|
|
453
|
+
js_element_scroll = f"arguments[0].scrollBy(0, {scroll_length or '1000'})"
|
|
451
454
|
web_element = internal_text.get_element_by_locator_text(locator, anchor)
|
|
452
455
|
scrollable_element = javascript.execute_javascript(js_get_parent_element, web_element)
|
|
453
456
|
current_pos = javascript.execute_javascript(js_element_position, scrollable_element)
|
|
@@ -461,22 +464,25 @@ def scroll_first_scrollable_parent_element(locator: str, anchor: str, text_to_fi
|
|
|
461
464
|
current_pos = javascript.execute_javascript(js_element_position, scrollable_element)
|
|
462
465
|
visible = internal_text.get_element_by_locator_text(text_to_find,
|
|
463
466
|
allow_non_existent=True)
|
|
464
|
-
logger.info(
|
|
465
|
-
old_pos
|
|
466
|
-
|
|
467
|
+
logger.info(
|
|
468
|
+
f'Old pos: {old_pos}\nNew pos: {current_pos}\nVisible: {visible}',
|
|
469
|
+
also_console=True,
|
|
470
|
+
)
|
|
467
471
|
else:
|
|
468
|
-
logger.info(
|
|
469
|
-
|
|
470
|
-
|
|
472
|
+
logger.info(
|
|
473
|
+
f'\nSlow mode is on, execution will only stop if the text "{text_to_find}" '
|
|
474
|
+
' is found or if the timeout is reached.',
|
|
475
|
+
also_console=True,
|
|
476
|
+
)
|
|
471
477
|
while not visible and time.time() < float(timeout) + start:
|
|
472
478
|
javascript.execute_javascript(js_element_scroll, scrollable_element)
|
|
473
479
|
time.sleep(.5)
|
|
474
480
|
visible = internal_text.get_element_by_locator_text(text_to_find,
|
|
475
481
|
allow_non_existent=True)
|
|
476
|
-
logger.info('\nVisible: {}'
|
|
482
|
+
logger.info(f'\nVisible: {visible}', also_console=True)
|
|
477
483
|
if visible:
|
|
478
484
|
return
|
|
479
|
-
raise QWebTextNotFoundError('Text {} not found.'
|
|
485
|
+
raise QWebTextNotFoundError(f'Text {text_to_find} not found.')
|
|
480
486
|
|
|
481
487
|
|
|
482
488
|
def scroll_dynamic_web_page(text_to_find: str, scroll_length: Optional[Union[int, str]],
|
|
@@ -485,7 +491,7 @@ def scroll_dynamic_web_page(text_to_find: str, scroll_length: Optional[Union[int
|
|
|
485
491
|
js_browser_height = "return window.innerHeight"
|
|
486
492
|
height = javascript.execute_javascript(js_browser_height) # Length of one scroll
|
|
487
493
|
js_current_pos = "return window.pageYOffset;"
|
|
488
|
-
js_scroll = 'window.scrollBy(0,{
|
|
494
|
+
js_scroll = f'window.scrollBy(0,{scroll_length or height})'
|
|
489
495
|
current_pos = javascript.execute_javascript(js_current_pos)
|
|
490
496
|
old_pos = None
|
|
491
497
|
start = time.time()
|
|
@@ -497,21 +503,25 @@ def scroll_dynamic_web_page(text_to_find: str, scroll_length: Optional[Union[int
|
|
|
497
503
|
current_pos = javascript.execute_javascript(js_current_pos)
|
|
498
504
|
visible = internal_text.get_element_by_locator_text(text_to_find,
|
|
499
505
|
allow_non_existent=True)
|
|
500
|
-
logger.info(
|
|
501
|
-
old_pos
|
|
502
|
-
|
|
506
|
+
logger.info(
|
|
507
|
+
f'\nOld pos: {old_pos}\nCurrent pos: {current_pos}\nVisible: {visible}',
|
|
508
|
+
also_console=True,
|
|
509
|
+
)
|
|
503
510
|
else:
|
|
504
|
-
logger.info(
|
|
505
|
-
|
|
506
|
-
|
|
511
|
+
logger.info(
|
|
512
|
+
'\nSlow mode is on, execution will only stop if '
|
|
513
|
+
f'the text "{text_to_find}" is found or if the timeout is reached.',
|
|
514
|
+
also_console=True,
|
|
515
|
+
)
|
|
507
516
|
while not visible and time.time() < float(timeout) + start:
|
|
508
517
|
javascript.execute_javascript(js_scroll)
|
|
509
518
|
time.sleep(.5)
|
|
510
519
|
visible = internal_text.get_element_by_locator_text(text_to_find,
|
|
511
520
|
allow_non_existent=True)
|
|
512
|
-
logger.info('\nVisible: {}'
|
|
521
|
+
logger.info(f'\nVisible: {visible}', also_console=True)
|
|
513
522
|
|
|
514
523
|
if visible:
|
|
515
524
|
return True
|
|
516
|
-
raise QWebTextNotFoundError(
|
|
517
|
-
text_to_find
|
|
525
|
+
raise QWebTextNotFoundError(
|
|
526
|
+
f'Could not find text "{text_to_find}" after scrolling for {current_pos} pixels.'
|
|
527
|
+
)
|
|
@@ -102,3 +102,10 @@ class Config:
|
|
|
102
102
|
trans_table = str.maketrans(dropped_chars_dict)
|
|
103
103
|
_string_value = string_value.lower().translate(trans_table)
|
|
104
104
|
return _string_value
|
|
105
|
+
|
|
106
|
+
def enforce_direction(self) -> bool:
|
|
107
|
+
search_direction = self.get_value("SearchDirection")
|
|
108
|
+
if search_direction:
|
|
109
|
+
return search_direction.endswith("!")
|
|
110
|
+
|
|
111
|
+
return False
|
|
@@ -31,6 +31,7 @@ from QWeb.internal import browser, javascript, util
|
|
|
31
31
|
from QWeb.internal.config_defaults import CONFIG
|
|
32
32
|
|
|
33
33
|
ACTIVE_AREA_FUNCTION: Optional[Callable[..., Any]] = None
|
|
34
|
+
DEFAULT_DISTANCE = 1000000.0 # Just some large number
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
def is_enabled(element: WebElement) -> bool:
|
|
@@ -103,7 +104,7 @@ def get_closest_element(locator_element: WebElement,
|
|
|
103
104
|
if not candidate_elements:
|
|
104
105
|
raise QWebElementNotFoundError('No elements visible')
|
|
105
106
|
closest_element_list = []
|
|
106
|
-
closest_distance =
|
|
107
|
+
closest_distance = DEFAULT_DISTANCE
|
|
107
108
|
for candidate_element in candidate_elements:
|
|
108
109
|
element_info = _list_info(candidate_element)
|
|
109
110
|
logger.debug("Measuring distance for: {}".format(element_info))
|
|
@@ -119,11 +120,17 @@ def get_closest_element(locator_element: WebElement,
|
|
|
119
120
|
elif distance < closest_distance:
|
|
120
121
|
closest_distance = distance
|
|
121
122
|
closest_element_list = [candidate_element]
|
|
123
|
+
# if search direction is "forced" and closest distance is in default value
|
|
124
|
+
# then we don't have the element on correct direction from the anchor
|
|
125
|
+
enforce_direction = CONFIG.enforce_direction()
|
|
126
|
+
if enforce_direction and closest_distance == DEFAULT_DISTANCE:
|
|
127
|
+
logger.debug(f'No elements in expected direction {CONFIG.get_value("SearchDirection")}')
|
|
128
|
+
raise QWebElementNotFoundError("No elements found in enforced direction")
|
|
122
129
|
|
|
123
130
|
closest_element = _get_closest_ortho_element(locator_element, closest_element_list)
|
|
124
131
|
|
|
125
|
-
logger.debug("Closest distance found is {}"
|
|
126
|
-
logger.debug("Closest element is: {
|
|
132
|
+
logger.debug(f"Closest distance found is {closest_distance}")
|
|
133
|
+
logger.debug(f"Closest element is: {_list_info(closest_element)}")
|
|
127
134
|
return closest_element
|
|
128
135
|
|
|
129
136
|
|
|
@@ -360,7 +367,7 @@ def _calculate_closest_distance(element1: WebElement, element2: WebElement) -> f
|
|
|
360
367
|
search_direction = CONFIG["SearchDirection"]
|
|
361
368
|
corners_locations1 = _get_corners_locations(element1)
|
|
362
369
|
corners_locations2 = _get_corners_locations(element2)
|
|
363
|
-
closest_distance =
|
|
370
|
+
closest_distance = DEFAULT_DISTANCE
|
|
364
371
|
for corner1 in corners_locations1:
|
|
365
372
|
for corner2 in corners_locations2:
|
|
366
373
|
distance = _manhattan_distance(corner1['x'], corner1['y'], corner2['x'], corner2['y'])
|
|
@@ -369,26 +376,28 @@ def _calculate_closest_distance(element1: WebElement, element2: WebElement) -> f
|
|
|
369
376
|
# small y is above
|
|
370
377
|
angle = math.degrees(
|
|
371
378
|
math.atan2(corner2['y'] - corner1['y'], corner2['x'] - corner1['x']))
|
|
372
|
-
|
|
379
|
+
|
|
380
|
+
if search_direction in ('down', 'down!'):
|
|
373
381
|
if not 5 < angle < 175:
|
|
374
382
|
logger.debug(
|
|
375
383
|
'Search direction is {} and element is not in arc'.format(search_direction))
|
|
376
|
-
distance =
|
|
377
|
-
elif search_direction
|
|
384
|
+
distance = DEFAULT_DISTANCE
|
|
385
|
+
elif search_direction in ('up', 'up!'):
|
|
378
386
|
if not -175 < angle < -5:
|
|
379
387
|
logger.debug(
|
|
380
388
|
'Search direction is {} and element is not in arc'.format(search_direction))
|
|
381
|
-
distance =
|
|
382
|
-
elif search_direction
|
|
389
|
+
distance = DEFAULT_DISTANCE
|
|
390
|
+
elif search_direction in ('left', 'left!'):
|
|
383
391
|
if not abs(angle) > 95:
|
|
384
392
|
logger.debug(
|
|
385
393
|
'Search direction is {} and element is not in arc'.format(search_direction))
|
|
386
|
-
distance =
|
|
387
|
-
elif search_direction
|
|
394
|
+
distance = DEFAULT_DISTANCE
|
|
395
|
+
elif search_direction in ('right', 'right!'):
|
|
388
396
|
if not -85 < angle < 85:
|
|
389
397
|
logger.debug(
|
|
390
398
|
'Search direction is {} and element is not in arc'.format(search_direction))
|
|
391
|
-
distance =
|
|
399
|
+
distance = DEFAULT_DISTANCE
|
|
400
|
+
|
|
392
401
|
if closest_distance > distance > 0:
|
|
393
402
|
closest_distance = distance
|
|
394
403
|
return closest_distance
|
|
@@ -517,7 +526,7 @@ def _get_closest_ortho_element(locator_element: WebElement,
|
|
|
517
526
|
elif list_len == 0:
|
|
518
527
|
raise IndexError
|
|
519
528
|
|
|
520
|
-
closest_distance =
|
|
529
|
+
closest_distance = DEFAULT_DISTANCE
|
|
521
530
|
for candidate_element in element_list:
|
|
522
531
|
distance = _calculate_closest_ortho_distance(locator_element, candidate_element)
|
|
523
532
|
logger.debug("Candidate {}: horizontal distance: {}".format(candidate_element, distance))
|
|
@@ -75,7 +75,7 @@ def wait_page_loaded() -> None:
|
|
|
75
75
|
try:
|
|
76
76
|
xhr.wait_xhr(timestr_to_secs(timeout))
|
|
77
77
|
except (WebDriverException, QWebDriverError) as e:
|
|
78
|
-
logger.
|
|
78
|
+
logger.debug(f'Unable to check AJAX requests due error: {e}')
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
def get_raw_html() -> str:
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
# ---------------------------
|
|
17
17
|
from typing import Any
|
|
18
|
+
|
|
18
19
|
# pylint: disable=line-too-long
|
|
19
20
|
import re
|
|
20
21
|
import string
|
|
@@ -26,7 +27,7 @@ class SearchStrategies:
|
|
|
26
27
|
MATCHING_INPUT_ELEMENT: str = '//*[(self::input or self::textarea) and (normalize-space(@placeholder)="{0}" or normalize-space(@value)="{0}")]'
|
|
27
28
|
CONTAINING_INPUT_ELEMENT: str = '//*[(self::input or self::textarea) and (contains(normalize-space(@placeholder),"{0}") or contains(normalize-space(@value),"{0}"))]'
|
|
28
29
|
|
|
29
|
-
ACTIVE_AREA_XPATH: str =
|
|
30
|
+
ACTIVE_AREA_XPATH: str = "//body"
|
|
30
31
|
|
|
31
32
|
TEXT_MATCH: str = '//*[not(self::script) and normalize-space(translate(., "\u00a0", " "))="{0}" and not(descendant::*[normalize-space(translate(., "\u00a0", " "))="{0}"])]|//input[(@type="button" or @type="reset" or @type="submit" or @type="checkbox") and normalize-space(translate(@value, "\u00a0", " "))="{0}"]'
|
|
32
33
|
|
|
@@ -46,7 +47,7 @@ class SearchStrategies:
|
|
|
46
47
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÅ", "abcdefghijklmnopqrstuvwxyzäöå"), \
|
|
47
48
|
translate("{0}", "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÅ", "abcdefghijklmnopqrstuvwxyzäöå"))]'
|
|
48
49
|
|
|
49
|
-
IS_MODAL_XPATH =
|
|
50
|
+
IS_MODAL_XPATH = "//body"
|
|
50
51
|
|
|
51
52
|
@staticmethod
|
|
52
53
|
def active_area_xpath_validation(xpath: str) -> str:
|
|
@@ -58,7 +59,7 @@ class SearchStrategies:
|
|
|
58
59
|
|
|
59
60
|
@staticmethod
|
|
60
61
|
def matching_input_element_validation(xpath: str) -> str:
|
|
61
|
-
if xpath ==
|
|
62
|
+
if xpath == "containing input element":
|
|
62
63
|
xpath = SearchStrategies.CONTAINING_INPUT_ELEMENT
|
|
63
64
|
SearchStrategies.verify_format_string(xpath, 1)
|
|
64
65
|
return SearchStrategies.clear_xpath(xpath)
|
|
@@ -74,13 +75,23 @@ class SearchStrategies:
|
|
|
74
75
|
@staticmethod
|
|
75
76
|
def clear_xpath(xpath: str) -> str:
|
|
76
77
|
if re.match("xpath *=", xpath, re.IGNORECASE):
|
|
77
|
-
return
|
|
78
|
+
return "".join(xpath.split("=")[1:])
|
|
78
79
|
return xpath
|
|
79
80
|
|
|
80
81
|
@staticmethod
|
|
81
82
|
def search_direction_validation(direction: str) -> str:
|
|
82
|
-
"""
|
|
83
|
-
valid_directions = [
|
|
83
|
+
"""Validates the search direction configuration"""
|
|
84
|
+
valid_directions = [
|
|
85
|
+
"up",
|
|
86
|
+
"down",
|
|
87
|
+
"left",
|
|
88
|
+
"right",
|
|
89
|
+
"closest",
|
|
90
|
+
"up!",
|
|
91
|
+
"down!",
|
|
92
|
+
"left!",
|
|
93
|
+
"right!",
|
|
94
|
+
]
|
|
84
95
|
direction = direction.lower()
|
|
85
96
|
if direction not in valid_directions:
|
|
86
97
|
raise ValueError("Wrong search direction")
|
|
@@ -89,8 +100,8 @@ class SearchStrategies:
|
|
|
89
100
|
@staticmethod
|
|
90
101
|
def _continuous_set(s: set, num: int) -> bool:
|
|
91
102
|
"""Verifies that a set has given number of continous values
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
starting from 0. E.g. 0,1,2,3 is 4 continuous values whereas
|
|
104
|
+
0,1,3,4 is not.
|
|
94
105
|
"""
|
|
95
106
|
|
|
96
107
|
return set.intersection(s, set(range(num))) == set(range(num))
|
|
@@ -120,7 +131,7 @@ class SearchStrategies:
|
|
|
120
131
|
continuous = False
|
|
121
132
|
for elem in parsed:
|
|
122
133
|
# field_name '' matches {}
|
|
123
|
-
if elem[1] ==
|
|
134
|
+
if elem[1] == "":
|
|
124
135
|
empty_placeholders += 1
|
|
125
136
|
# field_name '0' matches {0} etc.
|
|
126
137
|
elif elem[1] and elem[1].isnumeric():
|
|
@@ -129,15 +140,29 @@ class SearchStrategies:
|
|
|
129
140
|
# Position placeholders are in a set. They must start from zero
|
|
130
141
|
# so that we have {0}'s, {1}'s etc.
|
|
131
142
|
if index_placeholders:
|
|
132
|
-
continuous = SearchStrategies._continuous_set(
|
|
143
|
+
continuous = SearchStrategies._continuous_set(
|
|
144
|
+
index_placeholders, placeholder_num
|
|
145
|
+
)
|
|
133
146
|
|
|
134
147
|
if placeholder_num != (empty_placeholders + len(index_placeholders)):
|
|
135
|
-
raise ValueError(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
raise ValueError(
|
|
149
|
+
"xpath has invalid number of placeholders, got {}, {}".format(
|
|
150
|
+
empty_placeholders, len(index_placeholders)
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
empty_placeholders == placeholder_num
|
|
156
|
+
or len(index_placeholders) == placeholder_num
|
|
157
|
+
and continuous
|
|
158
|
+
):
|
|
140
159
|
pass
|
|
141
160
|
else:
|
|
142
|
-
raise ValueError(
|
|
143
|
-
|
|
161
|
+
raise ValueError(
|
|
162
|
+
"xpath should contain {} placeholders, got {}, {}, {}".format(
|
|
163
|
+
placeholder_num,
|
|
164
|
+
empty_placeholders,
|
|
165
|
+
len(index_placeholders),
|
|
166
|
+
continuous,
|
|
167
|
+
)
|
|
168
|
+
)
|
|
@@ -129,31 +129,36 @@ class Table:
|
|
|
129
129
|
table_element = text.get_element_using_anchor(table_elements, anchor)
|
|
130
130
|
if table_element:
|
|
131
131
|
return table_element
|
|
132
|
-
raise QWebElementNotFoundError('Table element not found by locator {}'
|
|
132
|
+
raise QWebElementNotFoundError(f'Table element not found by locator {locator}')
|
|
133
133
|
|
|
134
134
|
def get_table_cell(self, coordinates: str, anchor: str, **kwargs) -> WebElement: # pylint: disable=unused-argument
|
|
135
135
|
cell = None
|
|
136
136
|
try:
|
|
137
137
|
if '/' in coordinates:
|
|
138
|
-
cell = self.get_using_text_in_coordinates(coordinates, anchor)
|
|
138
|
+
cell = self.get_using_text_in_coordinates(coordinates, anchor, **kwargs)
|
|
139
139
|
else:
|
|
140
140
|
row, column = self._convert_coordinates(coordinates)
|
|
141
141
|
try:
|
|
142
142
|
cell = self.table.find_element(By.XPATH,
|
|
143
143
|
'.//tr[{0}]//td[{1}]'.format(row, column))
|
|
144
144
|
except AttributeError as e:
|
|
145
|
-
logger.debug('exception {}'
|
|
145
|
+
logger.debug(f'exception {e}')
|
|
146
146
|
self.update_table()
|
|
147
147
|
if cell:
|
|
148
148
|
if CONFIG['SearchMode']:
|
|
149
149
|
element.draw_borders(cell)
|
|
150
150
|
return cell
|
|
151
151
|
except (StaleElementReferenceException, NoSuchElementException) as e:
|
|
152
|
-
logger.debug('exception {}'
|
|
152
|
+
logger.debug(f'exception {e}')
|
|
153
153
|
self.update_table()
|
|
154
|
-
raise QWebElementNotFoundError(
|
|
154
|
+
raise QWebElementNotFoundError(
|
|
155
|
+
f'Cell for coords {coordinates} not found after'
|
|
156
|
+
)
|
|
155
157
|
|
|
156
|
-
def get_using_text_in_coordinates(self,
|
|
158
|
+
def get_using_text_in_coordinates(self,
|
|
159
|
+
coordinates: str,
|
|
160
|
+
anchor: str,
|
|
161
|
+
**kwargs) -> WebElement:
|
|
157
162
|
row: Optional[int]
|
|
158
163
|
column: Optional[int]
|
|
159
164
|
row_elem = None
|
|
@@ -164,7 +169,7 @@ class Table:
|
|
|
164
169
|
else:
|
|
165
170
|
row, _ = self._convert_coordinates(locator[0])
|
|
166
171
|
if locator[1].startswith('c?'):
|
|
167
|
-
column = self.get_cell_by_locator(locator[1][2:])
|
|
172
|
+
column = self.get_cell_by_locator(locator[1][2:], **kwargs)
|
|
168
173
|
else:
|
|
169
174
|
_, column = self._convert_coordinates(locator[1])
|
|
170
175
|
if row_elem:
|
|
@@ -183,7 +188,7 @@ class Table:
|
|
|
183
188
|
**kwargs) -> WebElement:
|
|
184
189
|
if int(index) < 1:
|
|
185
190
|
raise QWebValueError('Index should be greater than 0.')
|
|
186
|
-
table_cell = self.get_table_cell(coordinates, anchor)
|
|
191
|
+
table_cell = self.get_table_cell(coordinates, anchor, **kwargs)
|
|
187
192
|
if 'tag' in kwargs:
|
|
188
193
|
clickable_child = element.get_element_from_childnodes(table_cell,
|
|
189
194
|
str(kwargs.get('tag')),
|
|
@@ -193,7 +198,8 @@ class Table:
|
|
|
193
198
|
return clickable_child[int(index) - 1]
|
|
194
199
|
return table_cell
|
|
195
200
|
|
|
196
|
-
def get_cell_by_locator(self, locator: str) -> int:
|
|
201
|
+
def get_cell_by_locator(self, locator: str, **kwargs) -> int:
|
|
202
|
+
partial_match = util.par2bool(kwargs.get('partial_match', CONFIG['PartialMatch']))
|
|
197
203
|
rows = self.get_all_rows()
|
|
198
204
|
for i, r in enumerate(rows): # pylint: disable=unused-variable
|
|
199
205
|
cells = self.get_cells_from_row(r)
|
|
@@ -206,9 +212,13 @@ class Table:
|
|
|
206
212
|
value = javascript.execute_javascript('return arguments[0].value', c)
|
|
207
213
|
if value:
|
|
208
214
|
cell_text += str(value)
|
|
209
|
-
if
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
if partial_match:
|
|
216
|
+
if locator in cell_text:
|
|
217
|
+
return index + 1
|
|
218
|
+
else:
|
|
219
|
+
if locator == cell_text:
|
|
220
|
+
return index + 1
|
|
221
|
+
raise QWebValueError(f'Matching table cell not found for locator {locator}.')
|
|
212
222
|
|
|
213
223
|
def get_row(self, locator: str, anchor: str, row_index: bool = False, **kwargs
|
|
214
224
|
) -> Union[WebElement, int]:
|
|
@@ -225,7 +235,7 @@ class Table:
|
|
|
225
235
|
return index + 1
|
|
226
236
|
if matches:
|
|
227
237
|
return matches
|
|
228
|
-
raise QWebValueError('Matching table row not found for locator {}.'
|
|
238
|
+
raise QWebValueError(f'Matching table row not found for locator {locator}.')
|
|
229
239
|
|
|
230
240
|
def get_all_rows(self) -> list[WebElement]:
|
|
231
241
|
return javascript.execute_javascript('return arguments[0].rows', self.table)
|
|
@@ -260,8 +270,9 @@ class Table:
|
|
|
260
270
|
matches.append(row)
|
|
261
271
|
if matches and not anchor_text:
|
|
262
272
|
return matches[int(anchor)], row_index[int(anchor)]
|
|
263
|
-
raise QWebElementNotFoundError(
|
|
264
|
-
locator
|
|
273
|
+
raise QWebElementNotFoundError(
|
|
274
|
+
f'Row that includes texts {locator} and {anchor_text} not found'
|
|
275
|
+
)
|
|
265
276
|
|
|
266
277
|
def _convert_coordinates(self, coordinate_str: str) -> tuple[Optional[int], Optional[int]]:
|
|
267
278
|
"""Return row and column from coordinate string."""
|
|
@@ -52,7 +52,7 @@ def get_element_by_locator_text(locator: str,
|
|
|
52
52
|
no_raise = util.par2bool(kwargs.get('allow_non_existent', False))
|
|
53
53
|
if no_raise:
|
|
54
54
|
return None
|
|
55
|
-
raise QWebElementNotFoundError(e)
|
|
55
|
+
raise QWebElementNotFoundError(e) from e
|
|
56
56
|
if web_element:
|
|
57
57
|
if 'parent' in kwargs and kwargs['parent']:
|
|
58
58
|
tag_name = kwargs['parent']
|
|
@@ -201,7 +201,8 @@ def get_text_using_anchor(text: str, anchor: str, **kwargs) -> WebElement:
|
|
|
201
201
|
if not web_elements:
|
|
202
202
|
raise QWebElementNotFoundError('Webpage did not contain text "{}"'.format(text))
|
|
203
203
|
|
|
204
|
-
if
|
|
204
|
+
# return directly if 1 match and direction does not need to be checked
|
|
205
|
+
if len(web_elements) == 1 and not CONFIG.enforce_direction():
|
|
205
206
|
return web_elements[0]
|
|
206
207
|
# Found many elements, use anchors to determine correct element
|
|
207
208
|
correct_element = get_element_using_anchor(web_elements, anchor, **kwargs)
|
|
@@ -512,7 +512,7 @@ def close_all_browsers() -> None:
|
|
|
512
512
|
|
|
513
513
|
@keyword(tags=("Browser", "Verification"))
|
|
514
514
|
def verify_links(
|
|
515
|
-
url: str = "current", log_all: bool = False, header_only: bool = True, timeout=
|
|
515
|
+
url: str = "current", log_all: bool = False, header_only: bool = True, timeout=0
|
|
516
516
|
) -> None:
|
|
517
517
|
r"""Verify that all links on a given website return good HTTP status codes.
|
|
518
518
|
|
|
@@ -112,8 +112,8 @@ def set_config(par: str, val: Any) -> Any:
|
|
|
112
112
|
| ScreenShotType_ | Log html source, screenshot or both | screenshot |
|
|
113
113
|
+---------------------+-----------------------------------------+----------------+
|
|
114
114
|
| SearchDirection_ | Set relative search direction for | closest |
|
|
115
|
-
| | element search (up, down,
|
|
116
|
-
| |
|
|
115
|
+
| | element search (closest, up, down, left,| |
|
|
116
|
+
| | right, up!, down!, left!, right!) | |
|
|
117
117
|
+---------------------+-----------------------------------------+----------------+
|
|
118
118
|
| SearchMode_ | Options for highlighting elements found | draw |
|
|
119
119
|
| | by searches (None, debug, draw). | |
|
|
@@ -227,20 +227,50 @@ def set_config(par: str, val: Any) -> Any:
|
|
|
227
227
|
|
|
228
228
|
Set search direction for element search.
|
|
229
229
|
|
|
230
|
-
Search direction is "up", "down", "left", "right"
|
|
230
|
+
Search direction is "closest, "up", "down", "left", "right",
|
|
231
|
+
"up!", "down!", "left!", "right!".
|
|
231
232
|
"Closest" is the default value.
|
|
232
233
|
|
|
233
234
|
Elements are searched according to their relative position to anchor.
|
|
234
235
|
|
|
236
|
+
With this setting you can choose between two ways of searching:
|
|
237
|
+
|
|
238
|
+
- **normal mode**
|
|
239
|
+
- **strict mode** (ending with "!").
|
|
240
|
+
|
|
241
|
+
**Normal Mode**: In this mode, you start looking for something starting from a specific point
|
|
242
|
+
or direction you've chosen. If you can't find it there, the search will then try to find
|
|
243
|
+
the closest match, even if it's not exactly in the direction you started from.
|
|
244
|
+
|
|
245
|
+
**Strict Mode**: This mode is stricter. You also start searching from a specific direction,
|
|
246
|
+
but the big difference is that if what you're looking for isn't found exactly in that direction,
|
|
247
|
+
the search will fail.
|
|
248
|
+
It won't try to find the next closest thing. The search insists that the item must be found in
|
|
249
|
+
the direction you specified, or not at all.
|
|
250
|
+
It's important to note that this enforced format works only when you're searching for text
|
|
251
|
+
on a page, like when you're using commands to verify text is there (VerifyText)
|
|
252
|
+
or when you want to click on text (ClickText).
|
|
253
|
+
|
|
235
254
|
Examples
|
|
236
255
|
^^^^^^^^
|
|
256
|
+
|
|
237
257
|
.. code-block:: robotframework
|
|
238
258
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
259
|
+
*** Test Cases ***
|
|
260
|
+
SearchDirection Example
|
|
261
|
+
# finds input using text "My Locator" on the right of text "Robot"
|
|
262
|
+
SetConfig SearchDirection right
|
|
263
|
+
TypeText MyLocator Hello Robot
|
|
264
|
+
|
|
265
|
+
# finds input using text "My Locator" above of text "Robot"
|
|
266
|
+
SetConfig SearchDirection up
|
|
267
|
+
TypeText MyLocator Hello Robot
|
|
268
|
+
|
|
269
|
+
# When using strict mode (!), the test case fails if the locator text is
|
|
270
|
+
# not found in the correct direction from the anchor.
|
|
271
|
+
SetConfig SearchDirection left!
|
|
272
|
+
VerifyText Firstname anchor=Lastname
|
|
273
|
+
SetConfig SearchDirection closest
|
|
244
274
|
|
|
245
275
|
.. _linebreak:
|
|
246
276
|
|
|
@@ -47,11 +47,11 @@ def delete_all_cookies() -> None:
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
@keyword(tags=("Browser", "Getters"))
|
|
50
|
-
def list_cookies() -> list[dict[str, Any]]:
|
|
50
|
+
def list_cookies(log: bool = True) -> list[dict[str, Any]]:
|
|
51
51
|
r"""List all cookies in browser.
|
|
52
52
|
|
|
53
53
|
Cookies can be only listed when browser is open. Cookies are automatically
|
|
54
|
-
deleted when you Close All Browsers
|
|
54
|
+
deleted when you Close All Browsers.
|
|
55
55
|
|
|
56
56
|
Examples
|
|
57
57
|
--------
|
|
@@ -59,12 +59,19 @@ def list_cookies() -> list[dict[str, Any]]:
|
|
|
59
59
|
|
|
60
60
|
ListCookies
|
|
61
61
|
|
|
62
|
+
Parameters
|
|
63
|
+
----------
|
|
64
|
+
log : bool
|
|
65
|
+
If true, log list of cookies to html log file. If False, only returns cookie list.
|
|
66
|
+
Default is True.
|
|
67
|
+
|
|
62
68
|
Related keywords
|
|
63
69
|
----------------
|
|
64
70
|
\`DeleteAllCookies\`, \`IsCookie\`
|
|
65
71
|
"""
|
|
66
72
|
cookies_list = cookies.get_cookies()
|
|
67
|
-
|
|
73
|
+
if log:
|
|
74
|
+
logger.info(f"{cookies_list}")
|
|
68
75
|
return cookies_list
|
|
69
76
|
|
|
70
77
|
|
|
@@ -520,14 +520,16 @@ def get_attribute(locator: str,
|
|
|
520
520
|
|
|
521
521
|
Examples
|
|
522
522
|
--------
|
|
523
|
-
Using
|
|
524
|
-
element_type.
|
|
523
|
+
Using xpaths like with ClickElement etc. kw:s without specified
|
|
524
|
+
element_type. Index must be given if element is not unique:
|
|
525
525
|
|
|
526
526
|
.. code-block:: robotframework
|
|
527
527
|
|
|
528
528
|
${attribute_value} GetAttribute click_me id tag=button
|
|
529
529
|
${attribute_value} GetAttribute //*[@id\="click_me"] id
|
|
530
530
|
${attribute_value} GetAttribute xpath\=//*[@id\="click_me"] name
|
|
531
|
+
# Get id attribute value from 3rd matching element
|
|
532
|
+
${attribute_value} GetAttribute //button id index=3
|
|
531
533
|
|
|
532
534
|
GetAttribute using element_type attribute to locate element.
|
|
533
535
|
Text elements works as ClickText, VerifyText, GetText etc.:
|
|
@@ -574,7 +576,8 @@ def get_attribute(locator: str,
|
|
|
574
576
|
| Accepted kwargs:
|
|
575
577
|
| Any available for picked searching method.
|
|
576
578
|
| See interacting with text, item, input etc. elements from
|
|
577
|
-
| documentation
|
|
579
|
+
| documentation. When using xpath as locator **index** should be
|
|
580
|
+
| specified unless xpath matches to a single element.
|
|
578
581
|
|
|
579
582
|
Returns
|
|
580
583
|
-------
|
|
@@ -94,7 +94,8 @@ def use_table(
|
|
|
94
94
|
def verify_table(coordinates: str,
|
|
95
95
|
expected: str,
|
|
96
96
|
anchor: str = "1",
|
|
97
|
-
timeout: Union[int, float, str] = 0
|
|
97
|
+
timeout: Union[int, float, str] = 0,
|
|
98
|
+
**kwargs) -> None:
|
|
98
99
|
r"""Verify text in table coordinates.
|
|
99
100
|
|
|
100
101
|
Reads cell value from coordinates in active table and verifies it
|
|
@@ -122,6 +123,17 @@ def verify_table(coordinates: str,
|
|
|
122
123
|
distance.
|
|
123
124
|
timeout : str | int
|
|
124
125
|
How long we search before failing. Default = Search Strategy default timeout (10s)
|
|
126
|
+
kwargs :
|
|
127
|
+
| Accepted kwargs:
|
|
128
|
+
| **partial_match**: This argument lets you decide if you want to find column names
|
|
129
|
+
| by looking for an exact match to your search term or if a partial match is
|
|
130
|
+
| good enough. For example, when you're specifying which column to look at using
|
|
131
|
+
| a text-based method (like "r1/?cRobot"), this determines whether the system should
|
|
132
|
+
| look for an exact match to "Robot" or if it can work with columns that only partly
|
|
133
|
+
| match the word "Robot".
|
|
134
|
+
| It also applies to checking values: this setting controls whether a value that only
|
|
135
|
+
| partially matches your criteria is considered okay.
|
|
136
|
+
| Default: if partial_match is not given, the value of SetConfig PartialMatch is used.
|
|
125
137
|
|
|
126
138
|
Raises
|
|
127
139
|
------
|
|
@@ -132,10 +144,13 @@ def verify_table(coordinates: str,
|
|
|
132
144
|
----------------
|
|
133
145
|
\`ClickCell\`, \`GetCellText\`, \`GetTableRow\`, \`UseTable\`
|
|
134
146
|
"""
|
|
135
|
-
|
|
136
|
-
if isinstance(ACTIVE_TABLE, Table) is False:
|
|
147
|
+
if not isinstance(ACTIVE_TABLE, Table):
|
|
137
148
|
raise QWebInstanceDoesNotExistError('Table has not been defined with UseTable keyword')
|
|
138
|
-
|
|
149
|
+
table = Table.ACTIVE_TABLE.update_table()
|
|
150
|
+
|
|
151
|
+
table_cell = table.ACTIVE_TABLE.get_table_cell(coordinates, anchor, **kwargs)
|
|
152
|
+
partial_match = util.par2bool(kwargs.get('partial_match', CONFIG['PartialMatch']))
|
|
153
|
+
expected = f"{expected}*" if partial_match else expected
|
|
139
154
|
actions.get_element_text(table_cell, expected=expected, timeout=timeout)
|
|
140
155
|
|
|
141
156
|
|
|
@@ -187,9 +202,10 @@ def get_cell_text(coordinates: str,
|
|
|
187
202
|
----------------
|
|
188
203
|
\`ClickCell\`, \`GetTableRow\`, \`UseTable\`, \`VerifyTable\`
|
|
189
204
|
"""
|
|
190
|
-
|
|
191
|
-
if isinstance(ACTIVE_TABLE, Table) is False:
|
|
205
|
+
if not isinstance(ACTIVE_TABLE, Table):
|
|
192
206
|
raise QWebInstanceDoesNotExistError('Table has not been defined with UseTable keyword')
|
|
207
|
+
table = Table.ACTIVE_TABLE.update_table()
|
|
208
|
+
|
|
193
209
|
table_cell = table.get_table_cell(coordinates, anchor)
|
|
194
210
|
try:
|
|
195
211
|
text = actions.get_element_text(table_cell, timeout=timeout)
|
|
@@ -235,6 +251,16 @@ def click_cell(
|
|
|
235
251
|
index : int
|
|
236
252
|
Use index when table cell contains more than one clickable element and preferred one
|
|
237
253
|
is not the first one. Requires the use of tag and value should be > 0, default = 1.
|
|
254
|
+
kwargs :
|
|
255
|
+
| Accepted kwargs:
|
|
256
|
+
| **partial_match**: This argument lets you decide if you want to find column names
|
|
257
|
+
| by looking for an exact match to your search term or if a partial match is
|
|
258
|
+
| good enough. For example, when you're specifying which column to look at using
|
|
259
|
+
| a text-based method (like "r1/?cRobot"), this determines whether the system should
|
|
260
|
+
| look for an exact match to "Robot" or if it can work with columns that only partly
|
|
261
|
+
| match the word "Robot".
|
|
262
|
+
| Default: if partial_match is not given, the value of SetConfig PartialMatch is used.
|
|
263
|
+
|
|
238
264
|
|
|
239
265
|
Raises
|
|
240
266
|
------
|
|
@@ -245,9 +271,10 @@ def click_cell(
|
|
|
245
271
|
----------------
|
|
246
272
|
\`GetCellText\`, \`GetTableRow\`, \`UseTable\`, \`VerifyTable\`
|
|
247
273
|
"""
|
|
248
|
-
|
|
249
|
-
if isinstance(ACTIVE_TABLE, Table) is False:
|
|
274
|
+
if not isinstance(ACTIVE_TABLE, Table):
|
|
250
275
|
raise QWebInstanceDoesNotExistError('Table has not been defined with UseTable keyword')
|
|
276
|
+
table = Table.ACTIVE_TABLE.update_table()
|
|
277
|
+
|
|
251
278
|
table_cell = table.get_clickable_cell(coordinates, anchor, index, **kwargs)
|
|
252
279
|
actions.execute_click_and_verify_condition(table_cell, **kwargs)
|
|
253
280
|
|
|
@@ -292,9 +319,10 @@ def get_table_row(
|
|
|
292
319
|
----------------
|
|
293
320
|
\`ClickCell\`, \`GetCellText\`, \`UseTable\`, \`VerifyTable\`
|
|
294
321
|
"""
|
|
295
|
-
|
|
296
|
-
if isinstance(ACTIVE_TABLE, Table) is False:
|
|
322
|
+
if not isinstance(ACTIVE_TABLE, Table):
|
|
297
323
|
raise QWebInstanceDoesNotExistError('Table has not been defined with UseTable keyword')
|
|
324
|
+
table = Table.ACTIVE_TABLE.update_table()
|
|
325
|
+
|
|
298
326
|
return table.get_row(locator, anchor, row_index=True, **kwargs)
|
|
299
327
|
|
|
300
328
|
|
|
@@ -54,6 +54,23 @@ def verify_text(
|
|
|
54
54
|
|
|
55
55
|
VerifyText does not require for the text to be unique.
|
|
56
56
|
|
|
57
|
+
*Note: Slots are a bit unique as they do not have size/offset. This means
|
|
58
|
+
that our default visibility check will treat slots as not visible. If text is
|
|
59
|
+
directly on the slot, use visibility=False argument in VerifyText keyword. For example:*
|
|
60
|
+
|
|
61
|
+
.. code-block:: html
|
|
62
|
+
|
|
63
|
+
<slot>My Text</slot>
|
|
64
|
+
|
|
65
|
+
*The above needs visibility=False argument, as text is directly on the slot. However,
|
|
66
|
+
this one would work without turning visibility check off, since text is on a child
|
|
67
|
+
element under slot:*
|
|
68
|
+
|
|
69
|
+
.. code-block:: html
|
|
70
|
+
|
|
71
|
+
<slot><span>My Text</span></slot>
|
|
72
|
+
|
|
73
|
+
|
|
57
74
|
Examples
|
|
58
75
|
--------
|
|
59
76
|
.. code-block:: robotframework
|
|
@@ -413,7 +430,9 @@ def click_text(text: str,
|
|
|
413
430
|
If set to true, uses javascript instead of selenium to click element.
|
|
414
431
|
Accepted kwargs:
|
|
415
432
|
css=False/off: Use this to bypass css search when finding elements
|
|
416
|
-
by visible text
|
|
433
|
+
by visible text. In practise this means that also non-clickable texts
|
|
434
|
+
(e.g. spans) are considered. By default ClickText only finds texts that
|
|
435
|
+
are considered "clickable".
|
|
417
436
|
|
|
418
437
|
Related keywords
|
|
419
438
|
----------------
|
|
@@ -1213,7 +1232,7 @@ def scroll_text(text: str,
|
|
|
1213
1232
|
|
|
1214
1233
|
|
|
1215
1234
|
@keyword(tags=("input", "Text", "Interaction"))
|
|
1216
|
-
def write_text(text: str) -> None:
|
|
1235
|
+
def write_text(text: str, **kwargs) -> None: # pylint: disable=W0613
|
|
1217
1236
|
r"""Type text with single-character keys.
|
|
1218
1237
|
|
|
1219
1238
|
Parameters
|
|
@@ -1221,6 +1240,9 @@ def write_text(text: str) -> None:
|
|
|
1221
1240
|
text : str
|
|
1222
1241
|
Text to type.
|
|
1223
1242
|
|
|
1243
|
+
Accepted kwargs:
|
|
1244
|
+
delay = Time to wait (seconds) before typing.
|
|
1245
|
+
|
|
1224
1246
|
Examples
|
|
1225
1247
|
--------
|
|
1226
1248
|
.. code-block:: robotframework
|
|
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
|
|
File without changes
|