robotframework-browser
robotframework-browser copied to clipboard
screenshot filenames just replace `{index}` instead of properly formatting it.
screenshot paths with {index} in file name can not be created. {index} is always replaced by a number.
Therefore it is not possible like in SL to double the braces and create a file with {index} in name.
the following code should fix it.
.venv/lib/python3.11/site-packages/Browser/keywords/browser_control.py:94
def _get_screenshot_path(self, filename: str, fileType: str) -> Path:
if Path(filename).is_absolute():
directory = Path(filename).parent
filename = Path(filename).stem
else:
directory = self.screenshots_output
index = 0
while True:
index += 1
indexed = self._format_path(filename, index)
indexed_control = self._format_path(filename, sys.maxsize)
path = directory / indexed
if indexed == indexed_control or not path.with_suffix(f".{fileType}").is_file():
return path
def _format_path(self, file_path: str, index: int) -> str:
class _SafeFormatter(dict):
def __missing__(self, key):
return f"{{{key}}}"
return file_path.format_map(_SafeFormatter(index=index))