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

screenshot filenames just replace {index} instead of properly formatting it. #3385

Open
Snooz82 opened this issue Jan 20, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working priority: medium
Milestone

Comments

@Snooz82
Copy link
Member

Snooz82 commented Jan 20, 2024

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))
@Snooz82 Snooz82 self-assigned this Jan 20, 2024
@Snooz82 Snooz82 modified the milestones: v18.9.0, v18.10.0 Oct 6, 2024
@aaltat aaltat added bug Something isn't working priority: medium labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: medium
Projects
None yet
Development

No branches or pull requests

2 participants