Take Screenshot of a Website using Power Automate Desktop

Take Screenshot of a Website using Power Automate Desktop

This Power Automate Desktop flow asks the user for a website URL, opens it in Microsoft Edge, takes a screenshot, saves it to the Pictures folder, renames the file with the current date and time, and finally shows the file location in a message box.

Step-by-step explanation

  1. Ask the user for the website URL
    The flow starts with a Display input dialog action that shows a popup window titled “Take screenshot of a website”.
    • The dialog asks: "Please provide the website address to take screenshot of.."
    • A default URL is pre-filled: https://mspowerplatformtips.blogspot.com/
    • The user types or changes the URL and clicks OK or Cancel.
    • The entered URL is stored in the variable URL, and the button clicked is stored in ButtonPressed.
  2. Check if the user cancelled
    An If condition checks:
    IF ButtonPressed <> 'Cancel' THEN      
    This means:
    • If the user did not press Cancel (they clicked OK), the flow continues and takes a screenshot.
    • If the user pressed Cancel, nothing else in the block runs, and the flow ends.
  3. Get a folder path to store the screenshot
    The flow uses the Get special folder action:
    • It gets the path of the special folder MyPictures.
    • The path is stored in a variable named DesktopPath (the name is just a variable name; it actually holds the Pictures folder path).
    • This folder will be used to save the screenshot file.
  4. Launch Microsoft Edge and open the website
    The Launch Edge action runs:
    • It launches Microsoft Edge and opens the URL stored in URL.
    • The browser window is opened in Maximized mode.
    • Cache and cookies are not cleared (ClearCache: False, ClearCookies: False).
    • The browser instance is stored in the variable Browser so later actions can refer to it.
    There is also an ON ERROR block:
    • If an error occurs while launching the browser, it will retry up to 1 time.
    • Between retries, it waits for 2 seconds.

    Important: For web automation (like taking screenshots of web pages), the Power Automate browser extension must be installed in Edge, otherwise the automation actions may fail.

  5. Take a screenshot of the webpage
    After the page opens, the Take screenshot action runs:
    • It captures a screenshot of the currently opened page in the Browser instance.
    • The screenshot is saved as: %DesktopPath%\ScreenShot.png         
    • The file format is PNG.
  6. Close the browser
    The Close web browser action closes the Edge browser instance stored in Browser to avoid leaving unnecessary windows open after the screenshot is captured.
  7. Rename the screenshot with date and time
    The Rename file(s) action modifies the file name to add the current date and time:
    • It targets the file: %DesktopPath%\ScreenShot.png.
    • The current date and time are appended to the file name (not before or after the extension).
    • The separator between name and timestamp is a dash (-).
    • The format used is: yyyy-MM-dd@hh-mm (for example: ScreenShot-2025-11-24@09-30.png).
    • If a file with the same name already exists, it does nothing (IfFileExists: DoNothing).
    • The renamed file path is stored in a list variable RenamedFiles, and the first (and only) file path is RenamedFiles[0].
  8. Show the final file path to the user
    Finally, a Show message dialog appears:
    • Title: “Screenshot taken!”
    • Message text shows the full path where the screenshot is saved, using: %RenamedFiles[0]%
    • The dialog has an OK button and is shown as top-most.
    After the user clicks OK, the flow ends.

Full Power Automate Desktop code

# The 'Display input dialog' action prompts you to enter the address of the website you want to take a screenshot from.
Display.InputDialog Title: $'''Take screenshot of a website''' Message: $'''Please provide the website address to take screenshot of..''' DefaultValue: $'''https://mspowerplatformtips.blogspot.com/''' InputType: Display.InputType.SingleLine IsTopMost: True UserInput=> URL ButtonPressed=> ButtonPressed
# The following 'If' action checks whether the 'Cancel' button was pressed in the input dialog. If not, the flow takes a screenshot of the specified web page.
IF ButtonPressed <> $'''Cancel''' THEN
    # The 'Get special folder' action retrieves the path for the Desktop folder. This folder will store the taken screenshot.
    Folder.GetSpecialFolder SpecialFolder: Folder.SpecialFolder.MyPictures SpecialFolderPath=> DesktopPath
    /# The following actions launch the specified web page in a maximized window using Microsoft Edge, take a screenshot, and close the browser instance.

Please note that the Power Automate browser extension is required for this flow to work as expected.

Once you have it installed the extension lets you to automate things on the web like scripting, data extraction, testing, filling out forms and more.#/
    WebAutomation.LaunchEdge.LaunchEdge Url: URL WindowState: WebAutomation.BrowserWindowState.Maximized ClearCache: False ClearCookies: False Timeout: 60 BrowserInstance=> Browser
    ON ERROR REPEAT 1 TIMES WAIT 2
    END
    WebAutomation.TakeScreenshot.TakeScreenshotSaveToFile BrowserInstance: Browser File: $'''%DesktopPath%\\ScreenShot.png''' FileFormat: WebAutomation.FileFormat.Png
    WebAutomation.CloseWebBrowser BrowserInstance: Browser
    # The 'Rename file(s)' action appends the current date and time to the screenshot's file name.
    File.RenameFiles.RenameAddDateOrTime Files: $'''%DesktopPath%\\ScreenShot.png''' DateTimeToAdd: File.DateTimeToAdd.Current DateTimePosition: File.AddTextPosition.AfterName DateTimeSeparator: File.Separator.Dash DateTimeFormat: $'''yyyy-MM-dd@hh-mm''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> RenamedFiles
    Display.ShowMessageDialog.ShowMessage Title: $'''Screenshot taken!''' Message: $'''The screenshot is stored at:

%RenamedFiles[0]%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed2
END
  

Comments

Popular posts from this blog

Part 1: Creating Code Apps in Power Apps - A step-by-step guide (with real errors I faced & how I fixed them)

Calling Microsoft Graph API from Power Automate Using Azure App Services – Step-by-Step Guide

Step-by-Step Guide: Power Automate Custom Connector Using Graph API from Azure App Service