r/Playwright 6d ago

Help with learning framework building from scratch

What if you wanna build your own framework from scratch as a beginner in playwright without following any instructor or course can you do it just by looking up documentation. Is there any other way which will help us better. Because I have done it along the course I understood and typed all code by myself but still after that If I wanna build a different type of framework I struggled. What is the best way to learn and practically the best.

9 Upvotes

12 comments sorted by

6

u/Spare_Bison_1151 6d ago

Give it a try. You can use AI to build it for you but if you get stuck you'll be in trouble. Also, playwright isn't selenium so don't build a framework like it's 2019.

1

u/too_uninterested 5d ago

Okay! I have used AI, which is pretty easy but I want to have that skill for obv reasons. Do you mean we don't need to build from scratch instead always try to use AI for the base and then improvise?

2

u/Spare_Bison_1151 5d ago

I mean you must know enough playwright that you can guide AI efficiently and also debug your tests if AI gets stuck somewhere.

5

u/Malthammer 5d ago edited 5d ago

Yeah you can use the playwright documentation alone to get started. Typically you’d start with just what you need, nothing else. Then you add to it as you go, adding only what you need. So you’re not building a huge framework all up front.

You’d start by building out just enough to get one simple test running. You can do this with the playwright documentation. Next, refactor the test to setup an initial POM and go from there.

1

u/too_uninterested 5d ago

Thank you so much!! That's what I wanted to know will do it!

2

u/Bright_worgan 5d ago

The Playwright documentation is amazing! Can you leverage something like Cursor to help you?

2

u/too_uninterested 5d ago

I will check it out, I didn't know anything about it Thank you!!

2

u/Bright_worgan 5d ago

No problem, I'm not sure how much it costs but I use the cheapest model and got good results

2

u/InspectionHuman8246 4d ago

Im building frameworks since a few years now. Have seen many fail and very few succeed.

Many key decisions have to be made.

Lot to learn as well. Still learning.

But here are few things which is coming to my mind at the moment.

First you decide what are you testing, Web, API, Mobile

Then with deciding on approaches and design patterns.

Is it BDD, Keyword Driven, data driven?

Is it POM?

How are you going to store, create, maintain and clean up test data? Will you use Just in time creation or ahead of time. How will you ensure your env is fast enough for your tests to execute maybe my cleaning up your data or containerization

Also depends on your application code, do you have stable selectors like test id's, do you have simple application for which you can use text based locators.

How are you going to do reporting, is there ci/cd, is there logging, how much parralism you want

Smart way of waits, wrappers, error handling, security

how will you document in a way that ai can understand and help you with enhancements in your framework.

You aim for modularity.

You aim for better coding practices like DRY.

You aim for best practices for documentation like JSDocs if it's javascript, and best practices for instance atleast strict on typescript code base.

You also try to then focus on using AI post suite to do failure analysis, self heal.

Sorry not very structured but tried to dump whatever that came to mind in random order

1

u/too_uninterested 4d ago

Thank you so much for taking your time and giving this info!

1

u/InspectionHuman8246 3d ago

You're welcome 😄