Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 1b25bdf

Browse files
author
Igor Kozyrenko
authored
Rfe trello 20 add wait before capture (#416)
* docs: update CHANGELOG.md * feat: add wait_before_capture to config and check_settings * fix: skip test_should_wait_before_capture_in_config and test_should_wait_before_capture_in_check on windows * skip all incorrectly generated tests * test: add test_should_wait_before_capture_in_config and test_should_wait_before_capture_in_check
1 parent 7173b2a commit 1b25bdf

9 files changed

Lines changed: 86 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [vNext]
2+
### Added
3+
- Configurable delay before UFG snapshot (wait_before_capture api) [Trello 20](https://trello.com/c/qn2vPtpS)
4+
15
## [5.1.0] - 2022-03-01
26
### Added
37
- Target selection in Shadow DOM [Trello 2822](https://trello.com/c/o3Cl5GT2)

coverage-tests/configuration/python_overrides_universal.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ module.exports = {
1111

1212
// Failing on the universal server 1.10 and lower
1313
// check on new universal server version
14-
"check window on mobile web android": {skip: true}
14+
"check window on mobile web android": {skip: true},
1515

16+
// Temporarily disabled until generation fixed
17+
'should abort after close with vg': {skipEmit: true},
18+
'should abort unclosed tests': {skipEmit: true},
19+
'should abort unclosed tests with vg': {skipEmit: true},
20+
'should return aborted tests in getAllTestResults': {skipEmit: true},
21+
'should return aborted tests in getAllTestResults with vg': {skipEmit: true},
22+
'should return browserInfo in getAllTestResults': {skipEmit: true},
23+
'appium iOS check fully window with scroll and pageCoverage': {skip: true},
24+
'appium iOS check window region with scroll and pageCoverage': {skip: true},
25+
'should send agentRunId': {skip: true},
26+
'should waitBeforeCapture in open': {skip: true},
27+
'should waitBeforeCapture in check': {skip: true},
1628
}

eyes_selenium/applitools/common/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ class Configuration(object):
225225
converter=str,
226226
factory=lambda: get_env_with_prefix("DEBUG_SCREENSHOT_PREFIX", "screenshot_"),
227227
)
228+
wait_before_capture = attr.ib(
229+
metadata={JsonInclude.NON_NONE: True}, default=None
230+
) # type: Optional[int]
228231

229232
@property
230233
def enable_patterns(self):
@@ -492,6 +495,10 @@ def set_proxy(self, proxy):
492495
self.proxy = proxy
493496
return self
494497

498+
def set_wait_before_capture(self, milliseconds):
499+
self.wait_before_capture = milliseconds
500+
return self
501+
495502
@deprecated.attribute("Configuration features are not supported")
496503
def set_features(self, *_):
497504
pass

eyes_selenium/applitools/core/fluent/check_settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class CheckSettingsValues(object):
8484
variation_group_id = attr.ib(
8585
metadata={JsonInclude.NON_NONE: True}, init=False, default=None
8686
) # type: Optional[Text]
87+
wait_before_capture = attr.ib(
88+
metadata={JsonInclude.NON_NONE: True}, default=None
89+
) # type: Optional[int]
8790

8891

8992
Self = TypeVar("Self", bound="CheckSettings") # typedef
@@ -296,6 +299,10 @@ def timeout(self, timeout):
296299
self.values.timeout = timeout
297300
return self
298301

302+
def wait_before_capture(self, milliseconds):
303+
self.values.wait_before_capture = milliseconds
304+
return self
305+
299306
def __regions(self, regions, method_name, padding):
300307
if not regions:
301308
raise TypeError(

eyes_selenium/applitools/selenium/universal_sdk_types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ class EyesCheckConfig(object):
482482
@attr.s
483483
class EyesClassicConfig(object):
484484
wait_before_screenshots = attr.ib(default=None) # type: Optional[float]
485+
wait_before_capture = attr.ib(default=None) # type: Optional[int]
485486
stitch_mode = attr.ib(default=None) # type: Optional[StitchMode]
486487
hide_scrollbars = attr.ib(default=None) # type: Optional[bool]
487488
hide_caret = attr.ib(default=None) # type: Optional[bool]
@@ -566,6 +567,7 @@ def convert(cls, is_selenium, config):
566567
force_full_page_screenshot=config.force_full_page_screenshot,
567568
# EyesClassicConfig
568569
wait_before_screenshots=config.wait_before_screenshots,
570+
wait_before_capture=config.wait_before_capture,
569571
stitch_mode=config.stitch_mode,
570572
hide_scrollbars=config.hide_scrollbars,
571573
hide_caret=config.hide_caret,
@@ -631,6 +633,7 @@ class CheckSettings(MatchSettings, ScreenshotSettings):
631633
render_id = attr.ib(default=None) # type: Optional[Text]
632634
variation_group_id = attr.ib(default=None) # type: Optional[Text]
633635
timeout = attr.ib(default=None) # type: Optional[int]
636+
wait_before_capture = attr.ib(default=None) # type: Optional[int]
634637

635638
@classmethod
636639
def convert(cls, is_selenium, values):
@@ -649,6 +652,7 @@ def convert(cls, is_selenium, values):
649652
render_id=None, # TODO: verify
650653
variation_group_id=values.variation_group_id,
651654
timeout=values.timeout,
655+
wait_before_capture=values.wait_before_capture,
652656
# MatchSettings
653657
exact=None, # TODO: verify
654658
match_level=values.match_level,

tests/functional/eyes_selenium/selenium/test_eyes_new.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
import pytest as pytest
24
from selenium import webdriver
35
from selenium.webdriver.common.by import By
@@ -224,3 +226,38 @@ def test_get_all_test_results_aborts_eyes(runner_type):
224226

225227
results = runner.get_all_test_results()
226228
assert len(results) == 1
229+
230+
231+
@pytest.mark.skipif(sys.platform == "win32", reason="known to fail on windows")
232+
def test_should_wait_before_capture_in_config(local_chrome_driver):
233+
eyes = Eyes(VisualGridRunner())
234+
eyes.configure.add_browser(DesktopBrowserInfo(1200, 800, BrowserType.CHROME))
235+
eyes.configure.set_layout_breakpoints(True).set_wait_before_capture(2000)
236+
eyes.open(
237+
local_chrome_driver,
238+
"USDK Tests",
239+
"Wait before capture in config",
240+
{"width": 600, "height": 600},
241+
)
242+
local_chrome_driver.get(
243+
"https://applitools.github.io/demo/TestPages/waitBeforeCapture"
244+
)
245+
eyes.check("", Target.window())
246+
eyes.close()
247+
248+
249+
@pytest.mark.skipif(sys.platform == "win32", reason="known to fail on windows")
250+
def test_should_wait_before_capture_in_check(local_chrome_driver):
251+
eyes = Eyes(VisualGridRunner())
252+
eyes.configure.add_browser(DesktopBrowserInfo(1200, 800, BrowserType.CHROME))
253+
eyes.open(
254+
local_chrome_driver,
255+
"USDK Tests",
256+
"Wait before capture in check",
257+
{"width": 600, "height": 600},
258+
)
259+
local_chrome_driver.get(
260+
"https://applitools.github.io/demo/TestPages/waitBeforeCapture"
261+
)
262+
eyes.check("", Target.window().layout_breakpoints(True).wait_before_capture(2000))
263+
eyes.close()

tests/unit/eyes_common/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def test_default_values_selenium_configuration():
112112
assert conf.enable_cross_origin_rendering is True
113113
assert conf.dont_use_cookies is False
114114
assert conf.layout_breakpoints is None
115+
assert conf.wait_before_capture is None
116+
assert conf.wait_before_screenshots == 1000
115117

116118

117119
def test_set_value_to_sel_conf():
@@ -123,6 +125,7 @@ def test_set_value_to_sel_conf():
123125
conf.set_enable_cross_origin_rendering(False)
124126
conf.set_dont_use_cookies(True)
125127
conf.set_layout_breakpoints(True)
128+
conf.set_wait_before_capture(5)
126129

127130
assert conf.force_full_page_screenshot == True
128131
assert conf.wait_before_screenshots == 10000000
@@ -133,6 +136,7 @@ def test_set_value_to_sel_conf():
133136
assert conf.enable_cross_origin_rendering is False
134137
assert conf.dont_use_cookies is True
135138
assert conf.layout_breakpoints is True
139+
assert conf.wait_before_capture == 5
136140

137141

138142
def test_layout_breakpoints_list():

tests/unit/eyes_selenium/test_selenium_check_settings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ def test_default_check_settings():
3838
assert check_settings.values.disable_browser_fetching is None
3939
assert check_settings.values.layout_breakpoints is None
4040
assert check_settings.values.lazy_load is None
41+
assert check_settings.values.wait_before_capture is None
42+
43+
44+
def test_check_settings_change():
45+
check_settings = SeleniumCheckSettings()
46+
47+
check_settings.wait_before_capture(10)
48+
49+
assert check_settings.values.wait_before_capture == 10
4150

4251

4352
def test_check_region_and_frame_with_unsupported_input():

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ passenv =
3434
NO_COLOR
3535
PYTHON*
3636
deps =
37-
invoke
37+
invoke<1.7
3838
mock
3939
pytest<5
4040
npm

0 commit comments

Comments
 (0)