Skip to content

Commit

Permalink
(#32) Enable setting screenshot file name prefix (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harm10 authored Mar 3, 2023
1 parent 16884a8 commit f37baca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Mainframe3270/x3270.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,25 @@ def set_screenshot_folder(self, path: str) -> None:
logger.warn('Screenshots will be saved in "%s"' % self.imgfolder)

@keyword("Take Screenshot")
def take_screenshot(self, height: int = 410, width: int = 670) -> str:
def take_screenshot(
self, height: int = 410, width: int = 670, filename_prefix: str = "screenshot"
) -> str:
"""Generate a screenshot of the IBM 3270 Mainframe in a html format. The
default folder is the log folder of RobotFramework, if you want change see the `Set Screenshot Folder`.
The Screenshot is printed in a iframe log, with the values of height=410 and width=670, you
can change this values passing them to the keyword.
can change these values by passing them to the keyword.
The file name prefix can be set, the default is "screenshot".
The full file path is returned.
Example:
| ${filepath} | Take Screenshot |
| ${filepath} | Take Screenshot | height=500 | width=700 |
| Take Screenshot | height=500 | width=700 |
| Take Screenshot | filename_prefix=MyScreenshot |
"""
filename_prefix = "screenshot"
extension = "html"
filename_sufix = round(time.time() * 1000)
filepath = os.path.join(
Expand Down
12 changes: 12 additions & 0 deletions utest/x3270/test_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,15 @@ def test_take_screenshot(mocker: MockerFixture, under_test: x3270):
assert filepath == r".\screenshot_1000.html"
else:
assert filepath == "./screenshot_1000.html"

filepath = under_test.take_screenshot(250, 250, "MyScreenshot")

logger.write.assert_called_with(
'<iframe src="./MyScreenshot_1000.html" height="250" width="250"></iframe>',
level="INFO",
html=True,
)
if os.name == "nt":
assert filepath == r".\MyScreenshot_1000.html"
else:
assert filepath == "./MyScreenshot_1000.html"

0 comments on commit f37baca

Please sign in to comment.