Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#32) Enable setting screenshot file name prefix #81

Merged
merged 3 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Harm10 marked this conversation as resolved.
Show resolved Hide resolved

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"