Skip to content

Commit 9a352bc

Browse files
committed
better test of multiple outputs
1 parent bd43378 commit 9a352bc

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

atest/acceptance/10_lab/10_notebook.robot

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ IPython Notebook
1616
IPython Notebook Outputs
1717
Open JupyterLab
1818
Launch a new JupyterLab Document
19-
Add and Run Cell print("hello world")
19+
: FOR ${i} IN RANGE ${10}
20+
\ Add and Run Cell print("hello world " * ${i})
2021
Wait Until Kernel Is Idle
21-
Screenshot Each Output of Active Document ${OUTPUT_DIR}${/}ipython
22+
Screenshot Each Output of Active Document ${OUTPUT_DIR}${/}ipython_outputs/
2223

2324
*** Keywords ***
2425
Clean Up Everything

src/JupyterLibrary/keywords/screenshots.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@ class ScreenshotKeywords(LibraryComponent):
1717
@keyword
1818
def capture_element_screenshot(self, locator, filename):
1919
el = self.find_element(locator)
20+
bbox = self.normalize_bounding_box({**el.location, **el.size})
2021
BuiltIn().run_keyword("Capture Page Screenshot", filename)
21-
rect = {**el.location, **el.size}
22-
self.crop_image(filename, **self.round_dict(rect))
22+
self.crop_image(filename, **bbox)
2323

24-
def round_dict(self, dict):
24+
def normalize_bounding_box(self, bbox):
25+
""" Normalize a bounding box to reasonable defaults
26+
TODO: also handle larger-than-screen elements (if that's a thing)
27+
"""
2528
return {
26-
k: int(round(v)) if isinstance(v, float) else v for k, v in dict.items()
29+
k: (
30+
max(int(round(v)), 1)
31+
if k in ["width", "height"]
32+
else max(int(round(v)), 0)
33+
)
34+
for k, v in bbox.items()
2735
}
2836

2937
@keyword

0 commit comments

Comments
 (0)