Today, I’m excited to announce the release of a new open source project for test automation: Boa Constrictor, the .NET Screenplay Pattern!
The Screenplay Pattern helps you make better interactions for better automation. The pattern can be summarized in one line: Actors use Abilities to perform Interactions.
- Actors initiate Interactions. Every test has an Actor.
- Abilities enable Actors to perform Interactions. They hold objects that Interactions need, like WebDrivers or REST API clients.
- Interactions exercise behaviors under test. They could be clicks, requests, commands, and anything else.
This separation of concerns makes Screenplay code very reusable and scalable, much more so than traditional page objects. Check it out, here’s a C# script to test a search engine:
// Create the Actor IActor actor = new Actor(logger: new ConsoleLogger()); // Add an Ability to use a WebDriver actor.Can(BrowseTheWeb.With(new ChromeDriver())); // Load the search engine actor.AttemptsTo(Navigate.ToUrl(SearchPage.Url)); // Get the page's title string title = actor.AsksFor(Title.OfPage()); // Search for something actor.AttemptsTo(Search.For("panda")); // Wait for results actor.AttemptsTo(Wait.Until( Appearance.Of(ResultPage.ResultLinks), IsEqualTo.True()));
Boa Constrictor provides many interactions for Selenium WebDriver and RestSharp out of the box, like
Appearance shown above. It also lets you compose interactions together, like how
Search is a composition of typing and clicking.
Over the past two years, my team and I at PrecisionLender, a Q2 Company, developed Boa Constrictor internally as the cornerstone of Boa, our comprehensive end-to-end test automation solution. We were inspired by Serenity BDD‘s Screenplay implementation. After battle-hardening Boa Constrictor with thousands of automated tests, we are releasing it publicly as an open source project. Our goal is to help everyone make better interactions for better test automation.
If you’d like to give Boa Constrictor a try, then start with the tutorial. You’ll implement that search engine test from above in full. Then, once you’re ready to use it for some serious test automation, add the Boa.Constrictor NuGet package to your .NET project and go!
You can view the full source code on GitHub at q2ebanking/boa-constrictor. Check out the repository for full information. In the coming weeks, we’ll be developing more content and code. Since Boa Constrictor is open source, we’d love for you to contribute to the project, too!
Thanks for creating this framework. I’ve written a blog post about it where I do a comparison to a standard Page Object Model project. You can find the post here – https://jberri.gitlab.io/jgb/posts/2021-11-26-screenplay-vs-page-object-model/. Let me know your thoughts.
Thanks for taking the time to write this thoughtful article! I love it. I’d like to address a few points, though, that may help you form a better opinion.
First, we do have a static doc site:
It’s a work in progress, but it has lots of pages already. We also have a number of GitHub Issues to write more user guides:
Second, I believe your criticism of my introduction of the Page Object Model (POM) is a little unfair. It looks like you were referencing one of our intro videos or this article: https://q2ebanking.github.io/boa-constrictor/getting-started/page-objects/
As part of my explanation, I *did* evolve the POM implementation to use inheritance. I agree that most POM implementations do use inheritance, but not all. In fact, I have seen different teams at these different stages of POM “maturity” – raw SeWD calls, basic POs, advanced POs.
Furthermore, keep in mind that this article and especially the video needs a sensible narrative to showcase pain points. Ultimately, I intended to show how merciless refactoring of web UI interactions can ultimately evolve into the Screenplay Pattern, where page objects in various forms are just a step in that growth. My introduction of POM without inheritance was not a straw man argument. It was simply a stop on the path to highlight specific points that inheritance could (and could not) solve.
Third, Q2 uses Boa Constrictor for high-scale testing. Boa Constrictor is the cornerstone of a test automation solution that runs 5K-10K tests per day (~2K unique) against multiple test environments with unique configs at a scale of 50-100 tests in parallel. You can read all about it in a case study we wrote in collaboration with Tricentis/SpecFlow: https://automationpanda.com/2021/09/21/how-q2-uses-bdd-with-specflow-for-testing-precisionlender/