Keyword Feature wish for 'Capture Page Screenshot'

Can you please make it so that there’s an option for ‘Capture Page Screenshot’ so that the URL is always included?

Capture Page Screenshot   visible_url=true/on (larger modus needed)
Capture Page Screenshot   visible_url=false/off (compacter modus ok)

By default neither Selenium nor Playwright (as best as I can tell) supports a screenshot which includes the url bar. Although I see some suggestions about using the desktop tools to capture a screenshot of the desktop, as co-maintainer of SeleniumLibrary I see that outside of the scope for the SeleniumLibrary. It is possible with the explicit calling of the Capture Page Screenshot keyword to set the filename which you could add the url to the filename. For the automatic screenshot on failure renaming those I don’t see a clean solution but you could do something like record the current url or take an explicit screenshot adding the url to filename on failure within the teardown.

2 Likes

Hi @valentijnpeters ,

Given Ed’s answer and thinking about what you asked, I’m wondering if the url needs to be in the screenshot? if it was just in the robot log would that be all you need? it might be even better as you could copy the url if you wanted as it would be text.

Here’s my suggestion, create your own custom “on failure” keyword something like this:

*** Keywords ***
Capture Page Url And Screenshot
    ${URL}=    Get Location
    Log    ${URL}
    Capture Page Screenshot

Then just after you open the browser you can use Register Keyword To Run On Failure to use your newly created Capture Page Url And Screenshot instead of Capture Page Screenshot

Hopefully that does what you need?

Dave.

1 Like