Level Up Your Playwright Skills with Andrew Knight | Testμ 2024

Take your Playwright tests and go to the next level. Join the Workshop: Robustly Scaling Playwright Tests with Andrew Knight, Principal Architect at Cycle Labs! :dart:

Don’t miss out—register now and dive into the live session! :globe_with_meridians:

Got questions? Drop them below in the thread! :speech_balloon::point_down:

Can you discuss Playwright’s emphasis (at least in the documentation) on moving away from Xpath or CSS locators? More resiliency to changes in the DOM seems to be a valid reason for this, but isn’t specificity and potency of locators lost by forgoing DOM selectors?

Hi there,

If you couldn’t catch the session live, don’t worry! You can watch the recording here:

Here are some of the Q&As from this session:

What are the recommended approaches for managing authentication and sessions in Playwright tests?

Andrew Knight: Use Playwright’s built-in methods for handling authentication, such as setting cookies or using authentication tokens. Manage sessions by utilizing context objects to maintain state across different tests and ensure that authentication and session management are handled securely and consistently.

What are the good framework approaches we can adopt in playwright ?

Andrew Knight: Adopt frameworks like Playwright Test Runner to organize and manage test suites efficiently. Use custom fixtures for setting up test environments and leverage Playwright’s powerful APIs for handling various testing scenarios and configurations.

Can you dig into how to test PWAs using Playwright in TypeScript?

Andrew Knight: Testing PWAs with Playwright in TypeScript involves using Playwright’s APIs to simulate user interactions, test offline capabilities, and verify responsiveness. Write tests in TypeScript for type safety, ensuring that your code is robust and maintainable.

Which is better playwright or cypress and can they be integrated with AI

Andrew Knight: Playwright offers cross-browser testing capabilities and better support for modern web features, while Cypress provides a user-friendly interface and fast execution. Both tools can be integrated with AI to enhance testing capabilities, such as using AI for visual regression testing or intelligent test case generation.

How much of the web testing with Playwright in Typescript can be automated vs. manual?

Andrew Knight: Most web testing tasks with Playwright can be automated, including functional, integration, and end-to-end tests. Manual testing may be reserved for exploratory testing and cases where automated tests might not cover all user scenarios or interactions.

Now, let’s look at some unanswered questions.

What strategies can be used to reduce test flakiness when automating web tests with Playwright?

How does Playwright address common testing challenges like flaky tests and test maintenance?

How do you approach testing dynamic or interactive web elements with Playwright in TypeScript?

What are some advanced Playwright features in TypeScript that can help improve test reliability and efficiency?

Why is getByText(), placeholder etc. the best locator strategy for stable tests nowadays? A few years ago it was IDs and classes but now they are considered to be a bad practice. Texts can easily change as well, especially when you work with a CMS

How do you set up a Playwright project with TypeScript from scratch?

What are the best practices for structuring and organizing tests in a Playwright project?

How to explore Gen-Ai in playwright? What js libraries are there to look into?

What are some best practices for writing maintainable and scalable test scripts in Playwright using TypeScript?

How to make a Playwright test run faster than a Selenium test?

When the Feature Websocket interception will be available?

Can you discuss Playwright’s emphasis (in the docs) on moving away from Xpath or CSS locators? More resiliency to changes in the DOM seems to be a valid reason for this, but isn’t specificity and potency of locators lost by forgoing DOM selectors?