cucu 1.2.2__py3-none-any.whl → 1.2.3__py3-none-any.whl
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.
Potentially problematic release.
This version of cucu might be problematic. Click here for more details.
- cucu/browser/core.py +12 -0
- cucu/browser/selenium.py +46 -0
- cucu/environment.py +6 -6
- cucu/steps/browser_steps.py +64 -2
- cucu/utils.py +0 -13
- {cucu-1.2.2.dist-info → cucu-1.2.3.dist-info}/METADATA +1 -1
- {cucu-1.2.2.dist-info → cucu-1.2.3.dist-info}/RECORD +10 -10
- {cucu-1.2.2.dist-info → cucu-1.2.3.dist-info}/WHEEL +0 -0
- {cucu-1.2.2.dist-info → cucu-1.2.3.dist-info}/entry_points.txt +0 -0
- {cucu-1.2.2.dist-info → cucu-1.2.3.dist-info}/licenses/LICENSE +0 -0
cucu/browser/core.py
CHANGED
|
@@ -55,6 +55,18 @@ class Browser:
|
|
|
55
55
|
def close_window(self):
|
|
56
56
|
raise RuntimeError("implement me")
|
|
57
57
|
|
|
58
|
+
def get_tab_info(self):
|
|
59
|
+
raise RuntimeError("implement me")
|
|
60
|
+
|
|
61
|
+
def get_all_tabs_info(self):
|
|
62
|
+
raise RuntimeError("implement me")
|
|
63
|
+
|
|
64
|
+
def switch_to_nth_tab(self, tab_index):
|
|
65
|
+
raise RuntimeError("implement me")
|
|
66
|
+
|
|
67
|
+
def switch_to_tab_that_matches_regex(self, text):
|
|
68
|
+
raise RuntimeError("implement me")
|
|
69
|
+
|
|
58
70
|
def quit(self):
|
|
59
71
|
raise RuntimeError("implement me")
|
|
60
72
|
|
cucu/browser/selenium.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
|
+
import re
|
|
3
4
|
|
|
4
5
|
import chromedriver_autoinstaller
|
|
5
6
|
import geckodriver_autoinstaller
|
|
@@ -226,6 +227,51 @@ class Selenium(Browser):
|
|
|
226
227
|
raise RuntimeError("no previous browser tab available")
|
|
227
228
|
self.driver.switch_to.window(window_handles[window_handle_index - 1])
|
|
228
229
|
|
|
230
|
+
def switch_to_nth_tab(self, tab_number):
|
|
231
|
+
print(f"tab_number, {tab_number}")
|
|
232
|
+
window_handles = self.driver.window_handles
|
|
233
|
+
total_tabs = len(window_handles)
|
|
234
|
+
if tab_number > total_tabs:
|
|
235
|
+
raise RuntimeError(f"no {tab_number} browser tab available")
|
|
236
|
+
self.driver.switch_to.window(window_handles[tab_number])
|
|
237
|
+
|
|
238
|
+
def switch_to_tab_that_matches_regex(self, title_pattern):
|
|
239
|
+
window_handles = self.driver.window_handles
|
|
240
|
+
|
|
241
|
+
for handle in window_handles:
|
|
242
|
+
self.driver.switch_to.window(handle)
|
|
243
|
+
if re.search(title_pattern, self.driver.title):
|
|
244
|
+
return
|
|
245
|
+
|
|
246
|
+
raise Exception(f"No tab title matches pattern: {title_pattern}")
|
|
247
|
+
|
|
248
|
+
def get_tab_info(self):
|
|
249
|
+
window_handles = self.driver.window_handles
|
|
250
|
+
current_window = self.driver.current_window_handle
|
|
251
|
+
window_handle_index = window_handles.index(current_window)
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
"tab_count": len(window_handles),
|
|
255
|
+
"index": window_handle_index,
|
|
256
|
+
"title": self.driver.title,
|
|
257
|
+
"url": self.driver.current_url,
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
def get_all_tabs_info(self):
|
|
261
|
+
tabs_info = []
|
|
262
|
+
handles = self.driver.window_handles
|
|
263
|
+
for idx, handle in enumerate(handles):
|
|
264
|
+
self.driver.switch_to.window(handle)
|
|
265
|
+
tabs_info.append(
|
|
266
|
+
{
|
|
267
|
+
"index": idx,
|
|
268
|
+
"title": self.driver.title,
|
|
269
|
+
"url": self.driver.current_url,
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
return tabs_info
|
|
274
|
+
|
|
229
275
|
def back(self):
|
|
230
276
|
self.driver.back()
|
|
231
277
|
self.wait_for_page_to_load()
|
cucu/environment.py
CHANGED
|
@@ -10,7 +10,7 @@ from functools import partial
|
|
|
10
10
|
from cucu import config, init_scenario_hook_variables, logger
|
|
11
11
|
from cucu.config import CONFIG
|
|
12
12
|
from cucu.page_checks import init_page_checks
|
|
13
|
-
from cucu.utils import ellipsize_filename,
|
|
13
|
+
from cucu.utils import ellipsize_filename, take_screenshot
|
|
14
14
|
|
|
15
15
|
CONFIG.define(
|
|
16
16
|
"FEATURE_RESULTS_DIR",
|
|
@@ -264,11 +264,11 @@ def after_step(ctx, step):
|
|
|
264
264
|
if ctx.browser is not None and ctx.current_step.has_substeps is False:
|
|
265
265
|
take_screenshot(ctx, step.name, label=f"After {step.name}")
|
|
266
266
|
|
|
267
|
-
tab_info =
|
|
268
|
-
total_tabs = tab_info["
|
|
269
|
-
current_tab = tab_info["
|
|
270
|
-
title = tab_info["
|
|
271
|
-
url = tab_info["
|
|
267
|
+
tab_info = ctx.browser.get_tab_info()
|
|
268
|
+
total_tabs = tab_info["tab_count"]
|
|
269
|
+
current_tab = tab_info["index"] + 1
|
|
270
|
+
title = tab_info["title"]
|
|
271
|
+
url = tab_info["url"]
|
|
272
272
|
log_message = (
|
|
273
273
|
f"\ntab({current_tab} of {total_tabs}): {title}\nurl: {url}\n"
|
|
274
274
|
)
|
cucu/steps/browser_steps.py
CHANGED
|
@@ -32,7 +32,7 @@ def open_a_browser(ctx, url):
|
|
|
32
32
|
Given I open a browser at the url "https://www.google.com"
|
|
33
33
|
"""
|
|
34
34
|
if ctx.browser is None:
|
|
35
|
-
ctx.browser = open_browser(ctx)
|
|
35
|
+
ctx.browser = retry(open_browser)(ctx)
|
|
36
36
|
ctx.browsers.append(ctx.browser)
|
|
37
37
|
else:
|
|
38
38
|
logger.debug("browser already open so using existing instance")
|
|
@@ -43,7 +43,7 @@ def open_a_browser(ctx, url):
|
|
|
43
43
|
|
|
44
44
|
@step('I open a new browser at the url "{url}"')
|
|
45
45
|
def open_a_new_browser(ctx, url):
|
|
46
|
-
ctx.browser = open_browser(ctx)
|
|
46
|
+
ctx.browser = retry(open_browser)(ctx)
|
|
47
47
|
ctx.browsers.append(ctx.browser)
|
|
48
48
|
logger.debug(f"navigating to url #{url}")
|
|
49
49
|
ctx.browser.navigate(url)
|
|
@@ -219,6 +219,68 @@ def wait_to_switch_to_previous_browser_tab(ctx):
|
|
|
219
219
|
retry(switch_to_previous_tab)(ctx)
|
|
220
220
|
|
|
221
221
|
|
|
222
|
+
def switch_to_nth_tab(ctx, tab_number):
|
|
223
|
+
ctx.check_browser_initialized()
|
|
224
|
+
ctx.browser.switch_to_nth_tab(tab_number)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@step('I switch to the "{nth:nth}" browser tab')
|
|
228
|
+
def switch_to_nth_browser_tab(ctx, nth):
|
|
229
|
+
switch_to_nth_tab(ctx, nth)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@step('I wait to switch to the "{nth:nth}" browser tab')
|
|
233
|
+
def wait_to_switch_to_nth_browser_tab(ctx, nth):
|
|
234
|
+
retry(switch_to_nth_tab)(ctx, nth)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def switch_to_tab_matching_regex(ctx, regex):
|
|
238
|
+
ctx.check_browser_initialized()
|
|
239
|
+
ctx.browser.switch_to_tab_that_matches_regex(regex)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@step('I switch to the browser tab that matches "{regex}"')
|
|
243
|
+
def switch_to_browser_tab_matching_regex(ctx, regex):
|
|
244
|
+
switch_to_tab_matching_regex(ctx, regex)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
@step('I wait to switch to the browser tab that matches "{regex}"')
|
|
248
|
+
def wait_to_switch_to_browser_tab_matching_regex(ctx, regex):
|
|
249
|
+
retry(switch_to_tab_matching_regex)(ctx, regex)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@step('I save the browser tabs info to the variable "{variable}"')
|
|
253
|
+
def save_browser_tabs_info_to_variable(ctx, variable):
|
|
254
|
+
ctx.check_browser_initialized()
|
|
255
|
+
tabs_info = ctx.browser.get_all_tabs_info()
|
|
256
|
+
lst_tab_info = [
|
|
257
|
+
f"tab({tab['index'] + 1}): {tab['title']}, url: {tab['url']}"
|
|
258
|
+
for tab in tabs_info
|
|
259
|
+
]
|
|
260
|
+
config.CONFIG[variable] = lst_tab_info
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
@step("I list the current browser tab info")
|
|
264
|
+
def list_current_browser_tab_info(ctx):
|
|
265
|
+
ctx.check_browser_initialized()
|
|
266
|
+
tab_info = ctx.browser.get_tab_info()
|
|
267
|
+
current_tab = tab_info["index"] + 1
|
|
268
|
+
title = tab_info["title"]
|
|
269
|
+
url = tab_info["url"]
|
|
270
|
+
print(f"\ntab({current_tab}): {title}\nurl: {url}\n")
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
@step("I list all browser tabs info")
|
|
274
|
+
def list_browser_tabs_info(ctx):
|
|
275
|
+
ctx.check_browser_initialized()
|
|
276
|
+
all_tabs_info = ctx.browser.get_all_tabs_info()
|
|
277
|
+
for tab in all_tabs_info:
|
|
278
|
+
tab_index = tab["index"] + 1
|
|
279
|
+
title = tab["title"]
|
|
280
|
+
url = tab["url"]
|
|
281
|
+
print(f"\ntab({tab_index}): {title}\nurl: {url}\n")
|
|
282
|
+
|
|
283
|
+
|
|
222
284
|
def save_downloaded_file(ctx, filename):
|
|
223
285
|
ctx.check_browser_initialized()
|
|
224
286
|
|
cucu/utils.py
CHANGED
|
@@ -274,19 +274,6 @@ def take_screenshot(ctx, step_name, label="", element=None):
|
|
|
274
274
|
CONFIG["__STEP_SCREENSHOT_COUNT"] += 1
|
|
275
275
|
|
|
276
276
|
|
|
277
|
-
def get_tab_information(ctx):
|
|
278
|
-
driver = ctx.browser.driver
|
|
279
|
-
window_handles = driver.window_handles
|
|
280
|
-
current_window = driver.current_window_handle
|
|
281
|
-
window_handle_index = window_handles.index(current_window)
|
|
282
|
-
return {
|
|
283
|
-
"window_count": len(window_handles),
|
|
284
|
-
"current_index": window_handle_index,
|
|
285
|
-
"current_title": driver.title,
|
|
286
|
-
"current_url": driver.current_url,
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
277
|
def find_n_click_input_parent_label(ctx, input_element):
|
|
291
278
|
"""
|
|
292
279
|
Clicks the nearest parent <label> of an input elemnt (if input is visually hidden or size is zero).
|
|
@@ -2,16 +2,16 @@ cucu/__init__.py,sha256=YtuajsJBj3_DgNoygHen9gKojeQF523Oc27kyCUzoG0,1013
|
|
|
2
2
|
cucu/ansi_parser.py,sha256=_yTlqr6KruLsqgWR6BkpJUC3bmlQy_9JbkuxFx6Jrbo,2213
|
|
3
3
|
cucu/behave_tweaks.py,sha256=MqIL9BDHMvmyXyzkVGbD3wd8IP38_8pgp3NPGDWudm8,6873
|
|
4
4
|
cucu/config.py,sha256=12SXNtBSnD3N6K9DnCDYHZDA4_Wrh4g7whdgHDKSuPw,14022
|
|
5
|
-
cucu/environment.py,sha256=
|
|
5
|
+
cucu/environment.py,sha256=NTqvjddHrv4TPh9FNqq5xnwq21opf5HrKZJb3Oi2cg4,9950
|
|
6
6
|
cucu/helpers.py,sha256=l_YMmbuXjtBRo-MER-qe6soUIyjt0ey2BoSgWs4zYwA,36285
|
|
7
7
|
cucu/hooks.py,sha256=3Z1mavU42XMQ0DZ7lVWwTB-BJYHRyYUOzzOtmkdIsow,7117
|
|
8
8
|
cucu/logger.py,sha256=Y4eHmNFCphqXEzUQD-DJ8dsaqTNtqxmaKSCdo66Oc-g,3349
|
|
9
9
|
cucu/page_checks.py,sha256=CW1AqIxZ7rrLxpkf8nEFwcw6amnoN3Tb-acoN8dq3g0,2179
|
|
10
|
-
cucu/utils.py,sha256
|
|
10
|
+
cucu/utils.py,sha256=YMBJJrQGW7TaF-Og1ctAAa8RUNSNzQ9gJXD5kwsoWMA,9464
|
|
11
11
|
cucu/browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
cucu/browser/core.py,sha256=
|
|
12
|
+
cucu/browser/core.py,sha256=Ixcqr8l4xshzdW4AKcl1IkH98xHwRYsbt4snV7wUDlo,2692
|
|
13
13
|
cucu/browser/frames.py,sha256=IW7kzRJn5PkbMaovIelAeCWO-T-2sOTwqaYBw-0-LKU,3545
|
|
14
|
-
cucu/browser/selenium.py,sha256=
|
|
14
|
+
cucu/browser/selenium.py,sha256=J2oZmZxOcnlHp1QNPGgY55DzaMnVSV0MrZyVQkKzTBw,13176
|
|
15
15
|
cucu/browser/selenium_tweaks.py,sha256=oUIhWVhBZbc9qsmQUJMpIr9uUWKxtgZBcnySWU6Yttk,879
|
|
16
16
|
cucu/cli/__init__.py,sha256=uXX5yVG1konJ_INdlrcfMg-Tt_5_cSx29Ed8R8v908A,62
|
|
17
17
|
cucu/cli/core.py,sha256=sAvRIi_2cd4OQiKKISk7Web5-u5KWK1DNbayqav8tpY,26915
|
|
@@ -63,7 +63,7 @@ cucu/reporter/templates/layout.html,sha256=2iDRbm8atO8mgHWgijIvDCrBMKvcP6YHrmr95
|
|
|
63
63
|
cucu/reporter/templates/scenario.html,sha256=Eomxn7_gxrOeWPXKQrnUt3pgKlWeC3PTiM04LMtDI44,10113
|
|
64
64
|
cucu/steps/__init__.py,sha256=seSmASBlWu6-6wbFbvEbPwigBcRXiYP18C4X_2cW8Ng,753
|
|
65
65
|
cucu/steps/base_steps.py,sha256=0fPvdaKoan8lMAKrDnK0-zrALpxm11P1zVAY5CN7iXA,1893
|
|
66
|
-
cucu/steps/browser_steps.py,sha256=
|
|
66
|
+
cucu/steps/browser_steps.py,sha256=WryBbrryypFlVcRdTXmU37MQX0Yb7Ys_7ylysOYSYUY,12313
|
|
67
67
|
cucu/steps/button_steps.py,sha256=ej3urWbdffi7HimmPbrdUBkdLIA_xYcfLlsqOF-5_5s,2713
|
|
68
68
|
cucu/steps/checkbox_steps.py,sha256=B2HKFA-uwsrCa1DmzS7u1o1XH12b5BzLPg5qY1c445E,3386
|
|
69
69
|
cucu/steps/command_steps.py,sha256=nVCc8-TEitetk-zhk4z1wa0owqLQyHeQVH5THioUw-k,5094
|
|
@@ -86,8 +86,8 @@ cucu/steps/tables.js,sha256=Os2a7Fo-cg03XVli7USvcnBVad4N7idXr-HBuzdLvVQ,945
|
|
|
86
86
|
cucu/steps/text_steps.py,sha256=Jj_GHoHeemNwVdUOdqcehArNp7WM-WMjljA4w0pLXuw,2576
|
|
87
87
|
cucu/steps/variable_steps.py,sha256=WSctH3_xcxjijGPYZlxp-foC_SIAAKtF__saNtgZJbk,2966
|
|
88
88
|
cucu/steps/webserver_steps.py,sha256=wWkpSvcSMdiskPkh4cqlepWx1nkvEpTU2tRXQmPDbyo,1410
|
|
89
|
-
cucu-1.2.
|
|
90
|
-
cucu-1.2.
|
|
91
|
-
cucu-1.2.
|
|
92
|
-
cucu-1.2.
|
|
93
|
-
cucu-1.2.
|
|
89
|
+
cucu-1.2.3.dist-info/METADATA,sha256=9RmhkjPXv-XoPLHbVAsWPd3kAV0g5O-6HRfkY_mr0XI,16535
|
|
90
|
+
cucu-1.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
91
|
+
cucu-1.2.3.dist-info/entry_points.txt,sha256=YEXTyEfIZbcV0GJ9R3Gfu3j6DcOJJK7_XHkJqE3Yiao,39
|
|
92
|
+
cucu-1.2.3.dist-info/licenses/LICENSE,sha256=WfgJYF9EaQoL_OeWr2Qd0MxhhFegDfzWSUmvDTwFxis,1721
|
|
93
|
+
cucu-1.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|