File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
src/JupyterLibrary/keywords Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,10 @@ IPython Notebook
1616IPython 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 ***
2425Clean Up Everything
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments