robotframework-debuglibrary icon indicating copy to clipboard operation
robotframework-debuglibrary copied to clipboard

Suggested Keyword: View Screenshot

Open schinckel opened this issue 5 years ago • 1 comments

When debugging robot tests that use chromeheadless, I've found that more often than not I actually want to view a screenshot of what the browser is doing at the point in time when I drop into a Debug session.

This is not quite the same as just saving a screenshot, because the file should only be temporary.

Internally, I'm using something like:

    def view_screenshot(self):
        import subprocess
        import tempfile
        from robot.libraries.BuiltIn import BuiltIn

        selenium = Builtin().get_library_instance('SeleniumLibrary')
        filename = tempfile.mkstemp(suffix='.png')[1]

        subprocess.call([
            'open',
            selenium.capture_page_screenshot(filename)
        ])
        subprocess.call(['rm', filename])

Is this something you would be prepared to include? It's probably going to require a bit of tweaking (it's geared to macOS right now, which has an open command, for instance), but I'd be happy to submit a PR if you are interested.

schinckel avatar Jun 11 '20 07:06 schinckel

I think this feature would be very helpful to users. Contributions are welcome.

xyb avatar Jun 11 '20 09:06 xyb