Friday, March 27, 2026

Automatically Capturing Business Central Screenshots Using Playwright

by Steve Endow

I recently developed a new AppSource app for Business Central.  I used GitHub Copilot (GHCP) to create a nice user guide for the app, and asked Copilot to insert placeholders for screenshots.  The resulting 23 page user guide looks nice, but I discovered that it called for 21 screen shots.

Now that we've entered the age of AI and "agentic engineering", where an agent can commit and push for me so that I don't have to type or click at all, I have become impressively lazy.  Naturally, it would be uncivilized for me to manually save 21 screen shots.  That is sooo 2025.

While chatting with BC MVP Brad Prendergast, he sent me a post about something called Playwright.  It sounded vaguely familiar to me, because it was mentioned in the book Vibe Coding by Steve Yegge and Gene Kim.  I looked it up and (re) learned that Playwright is a browser automation tool.

Playwright Test is an end-to-end test framework for modern web apps. It bundles test runner, assertions, isolation, parallelization and rich tooling. Playwright supports Chromium, WebKit and Firefox on Windows, Linux and macOS, locally or in CI, headless or headed, with native mobile emulation for Chrome (Android) and Mobile Safari.

Okay, interesting.

So I ask GHCP:  Can Playwright take screen shots?

GHCP:  Yup.

And that is how I started a journey to spend hours building automated BC screen shot capture scripts using Copilot and Playwright.

Exactly 1280 x 720, with a specific row selected


In case you want to spend several thrilling hours wrangling an AI to get a few BC screen shots, here are links to my full documentation for implementing automated Business Central screen shot capture using an agent.

    Playwright for BC Screenshots and Testing v1.2.md

    Playwright for BC Screenshots and Testing v1.2.pdf


You probably don't want to read the PDF.  I would just have an agent read the MD file and setup a demo for you.


Observations:

Does it work?  Technically, yes.

Does it work well?  Define "well".

If I need 5-15 BC screen shots, is it worthwhile to use Playwright?  No.

If I need over 30 BC screen shots, is it worthwhile?  Maybe.

If I need to take 30+ screen shots with each AppSource app release in order to keep my app documentation updated, is it worthwhile?  Yes.


What is good about Playwright:  

1. If you're lazy like me, you'll enjoy watching an automated browser session navigate throughout BC and save screen shots while you're drinking your coffee and listening to music.  It's very futuristic.

2. You can ask for very specific screen shots.  "On the Activity Log page, make sure that you select a row with Event Type = API Request so that the payload is visible in the factbox."  And IT ACTUALLY PULLS THIS OFF!  Pretty darn impressive.

3. GHCP can use it to capture PNG images that are exactly 1280 x 720, which is what AppSource requires.  This is actually very handy.

4. If you are having to repeatedly take screen shots in BC for some reason, and if you are good at wrangling GHCP (or your preferred agent), then with some patience, you might be able to crank out a lot of screen shots.  But you will definitely want to review every single one to confirm that it captures what you want.

5. When you have 30+ screen shots saved to disk without even touching you're mouse, you will absolutely rationalize that the effort was totally worth it and that you are a genius for spending 6 hours to avoid 15 minutes of manual labor on your keyboard and mouse.


What is not so good about Playwright with Business Central:

1. The HTML / DOM / whatever used by Business Central is a hot mess.  A date field is apparently not really a date field.  It's some complex pile of stuff that Playwright has to decipher and then navigate through trial and error.  I (my agent) spent hours deciphering the BC page source and figuring out how to navigate in BC and on a page.  My guide attempts to help accelerate that process, but you'll likely need to refine further based on your navigation and automation requirements.  Detailed logging is essential, as it allows the agent to self-diagnose the issue without interrupting your latte sippin' and Led Zeppelin listenin'.

2. The AI agent can be flaky.  This isn't really Playwright's fault, but you'll get screen shots like 07-excel-download.png, even though your app doesn't have an Excel download feature. (true story)

3. Playwright's attempt to interact with BC can be flaky.  "Make sure that the API configuration fasttab is expanded for this screen shot", you will ask.  The AI will reply that it's triple double checked that the fasttab will be expanded.  But the screenshot will show the fasttab collapsed.  Sometimes the Playwright script works, and sometimes it doesn't, no matter how much time you spend trying to improve reliability.

4. Every time you run the screen shot capture scripts, around 5-10% of the screen shots won't be 100% correct.  Correct page, but not showing the desired fields.  Or not showing the dialog.  Or expanded fasttabs that cause the desired fields to be cut off from the bottom of the screen shot.


Steve Endow is a Microsoft MVP in Los Angeles.  He works with Dynamics 365 Business Central and related technologies.

You can also find him on X and YouTube, or through these links:  links.steveendow.com 

No comments:

Post a Comment

All comments must be reviewed and approved before being published. Your comment will not appear immediately.

Automatically Capturing Business Central Screenshots Using Playwright

by Steve Endow I recently developed a new AppSource app for Business Central.  I used GitHub Copilot (GHCP) to create a nice user guide for ...