Imagine this: You're documenting an unreleased feature, and your documentation requires screenshots. However, you're working in an internal environment that includes features you don't want to reveal to the public. What do you do?
We faced this exact situation during the API Summit release when we needed to capture screenshots of the new Kong Konnect Plus dashboard while our internal environment also showcased Mesh Manager features.
In days gone by, tackling such a challenge meant delving into browser dev tools, meticulously hiding elements each time, and redoing the process after refreshing the browser. Now, there’s a better way. Let me introduce you to shot-scraper.
Kong ❤️ shot-scraper
At Kong, we’ve adopted shot-scraper, a tool for taking automated screenshots of websites, as part of our core workflow. We’ve even extended shot-scraper with the capability to run macros.
Macros are predefined JavaScript functions that can be executed at specific moments, enhancing your ability to interact with the web page and set up conditions prior to capturing the screenshot.
To solve the issue outlined above, I crafted a simple shot-scraper macro to remove elements from the page:
4. Interact with the page like a user. Here, we configure a graph in our Analytics dashboard builder:
- output:../../app/_assets/images/docs/konnect/custom-reports/api-usage-by-application.pngurl: https://cloud.konghq.com/us/analytics/reports/create
wait:4000width:1920height:1080javascript:|async()=>{// Configure the report we want to seeconst form =document.querySelector(".report-form form");// Set the report title form.querySelector("h1").textContent="API Usage by Application (last 30 days)";awaitsleep(500);// Select "Vertical Bar Chart" and wait for the UI to updateawaitactivateByTestId('chart-type-VerticalBar');// And the time durationawaitactivateByTestId('k-datetime-picker-display');awaitactivateByTestId('select-timeframe-30d');awaitactivateByTestId('k-datetime-picker-submit');// Group by Service form.querySelector(".select-group-by .k-select-input").click();awaitsleep(200);awaitactivateByTestId('k-select-item-Service');// Then by Application form.querySelector(".select-then-by .k-select-input").click();awaitsleep(200);awaitactivateByTestId('k-select-item-Application');// Wait for the chart to renderawaitsleep(1000);// The "selector" option didn't work well for some reason. This takes a nice screenshot without sidebar/headercleanupPage();}
Using shot-scraper, our docs team can write scripts once and have screenshots that are up-to-date, accurate, and reproducible by anyone on the team.
Why do you need automated screenshots for docs?
Screenshots in docs, in my experience, struggle with the following things:
Inaccuracy: The UI evolves, but the screenshots remain static.
Inconsistent appearances: Screenshots vary in size, resolution, and quality.
Resource consumption: Keeping these elements synchronized with the rapid pace of UI development consumes valuable time.
So, what's the solution when you want accurate screenshots without spending hours on cropping and resizing? Automation!
This is the only way to ensure that you are insulated from the pace of UI development and design while still being able to provide screenshots in your documentation.
For the Kong Docs team, shot-scraper is an invaluable tool that allows us to provide accurate documentation including screenshots to our readers.
Tips for automating screenshot workflows
If you're considering making the transition from manual to automated screenshot workflows, here are some practical tips:
Prune existing screenshots: Ensure that every screenshot serves a clear purpose. Screenshots are essential communication tools in documentation; they should convey key concepts, generate user interest, or showcase a visually appealing UI. However, they shouldn't compensate for poor UX design.
Build a process: Build a process around shot-scraper, or build shot-scraper into an existing process. Whether that’s a release process that concludes with running shot-scraper. Or a GitHub action that automates running shot-scraper. Creating a dozen scripts to never run them is just as much of a waste of resources as trying to configure your dev tools to take the same screenshot several times.
Advocate for your approach: Advocating for this approach is a vital part of any docs-as-code strategy. Just like other aspects like version control, automated testing, and plain text documentation, it requires a collective effort.
To successfully implement shot-scraper, everyone on your team should understand its value. Encourage your team members to embrace automation by showcasing the significant time savings it offers and its contribution to documentation accuracy. This approach can benefit not only the documentation team but also other departments, such as design teams, who can confidently make UI changes without burdening the documentation process.
Shot-scraper as part of your docs arsenal can help bring efficiency, accuracy, and efficacy to your documentation.
Few things are more frustrating than encountering a product with either no documentation or worse: documentation that leads you astray. When it comes to developing APIs, schemas typically define how requests and responses are formatted and guide how
Angel Guarisma
Use ChatGPT to Develop a SOAP/XML Custom Kong Konnect Plugin
Today, APIs are based on modern communication patterns: REST, GraphQL, or gRPC. But two decades ago, the majority of Web Services were developed with SOAP/XML.
In this blog, we’ll explain how Kong Konnect can manage SOAP/XML Web Services by creat
Real-time Data Analytics Platform from Zero to One
At the beginning of 2021, a brand new data team was assembled to build a real-time data platform for Kong’s SaaS platform, Konnect. Our mission is to provide top-notch real-time API analytics feat
Zhong Chen
API Product Management Guide: 6 Strategies for the Full Lifecycle
APIs are the connective tissue of digital products and services, and they're the lifeblood of AI. APIs shape customer experiences, power partner ecosystems, and accelerate enterprise innovation. As organizations double down on API-first strategies,
If you take a step back and think about today’s software development landscape, you could argue that documentation is just as important as the code itself. That’s because traditional documentation workflows — where documentation is manually updat
Kong
Cut Costs, Boost Speed: The AI Proxy Revolution for Developers
The AI Proxy Revolution has changed the way developers operate, helping save money and speed up development. This new approach improves how systems talk to each other and allows for quicker, more efficient data exchange. Modern software development
Key Takeaways API testing is crucial for ensuring the reliability, security, and performance of modern applications. Different types of testing, such as functional, security, performance, and integration testing, should be employed to cover all aspe
Adam Bauman
Ready to see Kong in action?
Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.