r/softwaretesting • • Jan 14 '24

Setting up a test automation framework from scratch

Hey fellow testers

I've recently realized the importance of being able to set up a test automation framework from scratch, as it seems to be a crucial skill in many job descriptions nowadays. While I've contributed to existing frameworks in my previous jobs, I haven't had the chance to create one entirely on my own.

I've dabbled in creating local frameworks for practice using tools like Cypress and Playwright, but I'm now looking to take this to a more professional level. I have a few questions and would appreciate any insights or advice you could share:

  1. Is there much difference between setting up a small framework (as seen in tutorials) and one for professional work?
    I'm curious about the nuances and challenges that come with setting up a framework for real-world, professional projects. What should I keep in mind that might not be covered in basic tutorials?

  2. Should I think of a structure for the project, such as using the Page Object Model (POM) or any other recommended approaches? Why or why not?
    I've heard about POM, but are there other structures or design patterns I should consider? What are the pros and cons, and how do they impact maintainability and scalability?

  3. Are there any aspects or decisions that I might not be aware of (the unknown unknowns) that could be crucial during the framework setup?
    I want to make informed decisions, so if there's anything I should be aware of that might not be obvious, please share your experiences.

  4. Is the foundational process of setting up a test automation framework generally the same, with variations due to tool-specific features and requirements?
    I'm particularly interested in Playwright and want to understand if the overall process remains consistent across tools, with variations influenced by tool-specific nuances. Are there fundamental principles that can be easily transferred, or does each tool demand a more specific approach? Any advice or resources specific to navigating these tool-specific differences would be greatly appreciated.

  5. Are there any good resources that discuss setting up a test automation framework in a workplace?
    I'm looking for materials that provide guidance on creating documentation, choosing tools and languages to facilitate collaboration, and making it easier for others to contribute.

  6. Speaking of documentation, what kind of documents should I create?
    Should I create documentation outlining the framework structure, tools used, and any coding standards or guidelines? How can I make it easy for others to understand and contribute to the project?

  7. If you have experience with Playwright, could you share any specific resources or wisdom on setting up a framework using this tool?
    I'm particularly interested in diving deeper into Playwright, so any guidance or experiences you can share would be immensely helpful.

  8. I have never set up a framework from scratch, but if I want to change a job to one which requires it, is it a good idea to have a github where one is set up and its working? If yes, could you please point to such repositories where similar projects exist?

Thanks in advance for any advice, tips, or resources you can provide!

39 Upvotes

28 comments sorted by

6

u/Yogurt8 Jan 14 '24

It's difficult to say for sure without knowing what tutorials you are learning from and what topics are covered in them.

You want the project to integrate seamlessly with the CI system used by the developers, potentially utilizing containerization. You'd want to create the right abstractions in the data, UI, and API layers. URL management, configuration, secrets, basic project setup, dependencies, linting and/or style guides, code review/PR process, and the test strategy.

2

u/OwnVeterinarian9444 Jan 14 '24

em used by the developers, potentially utilizing containerization. You'd want to create the right abstractions in the data, UI, and API layers. URL management, configuration, secrets, basic project setup, dependencies, linting and/or style guides, code review/PR process, and the test strategy.

wow, sounds complex, but I've met all of these here and there before - is there a good source you'd recommend where I'd read about these? thanks!

4

u/darkkite Jan 14 '24

google

2

u/OwnVeterinarian9444 Jan 14 '24

thanks for your answer, I google a lot, and Im actually going through a course at the minute - I was hoping if there is a reliable source where I could find a good high-level explanation, note I was not asking for a straight out answer, but rather a recommendation.

1

u/darkkite Jan 14 '24

the real answer is, most never have all the answers, but as long as you know the fundamentals and google the bits you don't know you should be able to get your answers. the industry changes fast in some areas and slowly in others.

2

u/latnGemin616 Jan 14 '24

Is there much difference between setting up a small framework (as seen in tutorials) and one for professional work?

To be honest, the short answer is no. However, that's not to say that the environment you're working in won't have it's own set of "particulars".

That being said, I was working with a tutorial using python that had all the things I needed plus a reporting mechanism in Allure that didn't work in the professional environment I was operating in. I still employed my framework and had a workaround for the reporting. My boss loved it (for the short time I was there).

Should I think of a structure for the project, such as using the Page Object Model (POM) or any other recommended approaches? Why or why not?

Short answer ... yes. You should want to make your framework scalable, flexible, and maintainable. It should be easy enough that someone net-new could be onboarded in minutes and learn how it works. I'm also quick to point out I loathe over-engineering a solution. Simplicity is the best.

1

u/OwnVeterinarian9444 Jan 14 '24

thanks for your answer, mind sharing what tutorial was it? :)

1

u/latnGemin616 Jan 14 '24

It was a long time ago, on udemy.

2

u/Ikeeki Jan 14 '24

The test automation framework really depends on what you’re trying to automate and what the goals are for your company.

But the second half of the equation is when and how to run those automation tests (CI/CD like GH Actions) which is something you didn’t mention in your post (unless I missed it :))

1

u/OwnVeterinarian9444 Jan 14 '24

I havent and absolutely should have - could you please let me know what's important to know regarding the CI/CD or any good source that's good quality and will get me started quickly?

also, how does the framework differs based on the goals? I believe the company I will do it for will most likely focus on E2E GUI regression automation, what are the other options?

3

u/Longjumping-Ad7478 Jan 14 '24

Well when you stick to software development pattern guidelines when writing ATC, framework kind of appears naturally. For example: you create page factories package( where you can get all page element locators), page helper(actions) factory( with different methods of page object interactions) package, web driwer factory( to initialize webdriver for different browsers) and default settings, assertions factory ( it needed) etc. And then you can write two line methods in your tests for checking things. Like shopPageHelper.clickButton(shopPage.buyButton); assert.popUpCheckout(true); Or one liner methods in case using builder patterns.

1

u/KatAsh_In Jan 16 '24

You could have simply said "SCREENPLAY"

1

u/AncientBattleCat Jan 14 '24
  1. You have to think about scaling and code quality.

  2. Depends. Cypress doesnt need one (at least authors say so). PO is for DRY mostly.

  3. Do not use pure Selenium . I am tired of convincing people that framework should do it from the box

(Cypress, Selenide, PW)

4. Again depends. Some frameworks manage it all. Some need tuning. Some have limitations (Cypress has not tab button, no

native download validation, no logging, no soft asserts and so on). You can add some plugins, however.

5. No. Srsly. 98 % of articles are garbage. Same ol download selenium and driver BS.

6. I do create an excel sheet and name my test cases like TC1, TC2 ... . Also I some description column and status column.

That works. Again jira, bugzilla whatever the hell people are using is a) overkill in most cases b) complex and insanely huge

instruments to manage a damn test case statuses (that's all it boils down to).

7. I would suggest scrapping github. You can find a good project examples there ocasionally.

8. I have personal one, for portfolio. Can't share. This acc is anonymous.

Github is ok'ish as long as you keep the project private and don't commit sensetive data (like pass or urls).

1

u/OwnVeterinarian9444 Jan 14 '24

regarding 8.. so I should start one to show that I can do it, but make sure not to store sensitive data (url and passwords) as a plain text, but instead maybe store then in some test data, and gitignore it while pushing it to my repo? Or there's a better way of doing it?

thanks a lot for your reply :)

4

u/hydraBeHailed Jan 14 '24

In my experience, I've never had a portfolio showing anything. My github profile is private, but if anyone visits it they will see my commit history/activity and nothing else.

In all the roles I've applied for, all that matters is nailing the live coding challenge (basically showing your problem solving skills and being able to communicate and asking the right questions) and getting the take home test challenge to pass after running it (they honestly don't care how, as long as it passes). I've never used Java before, and was given a test challenge in Java on Hackerrank that required me to finish some test cases and update others so that they pass.. spent most of the time googling syntax.

Again, this is my own experience, it is possible that most companies will look up your github to check your portfolio

1

u/OwnVeterinarian9444 Jan 14 '24

uggest doing everything contrary to what everyone in the industry is doing? Seems like a disaster waiting to happen.

ohh yes I totally agree, but at this new work I think of.. they ask if I can set up a framework from scratch, so it would be useful I actually built one from scratch to make sure I am even able to deliver to them.

3

u/[deleted] Jan 14 '24

So you would suggest doing everything contrary to what everyone in the industry is doing? Seems like a disaster waiting to happen.

0

u/AncientBattleCat Jan 14 '24

Yup. Selenium is not a test automation tool. It is even written on their official website. Also you have eco system there, where one can look up for good framework (selenium "wrapper" as people say). Well in some cases it is not just "wrapper". How does selenium handle dynamic nature of modern JS pages? It doesn't lol. You can write some waiters, some waiter wrappers that travers through the dom and hope nothing lags or rebuild at the last moment. You hope back-end is actually responding on UI calls , while UI is already there. Trust me I've been there and done that. Selenium is as ugly as pure C when It comes to test automating. I know most of industry uses it. Well, I believe they have ton of time money and most importantly patience. Did you know you can't mix expl/impl waits because it literally leads to undefined behaviour, where even selenium maintainers don't know the outcome?) Just as any low level instrument you should use selenium for once to deliberately stay away from it for the rest of your life. Sorry for long response.

6

u/ps4facts Jan 14 '24

Selenium maintainers do know the outcome of mixing implicit/explicit waits... Simon Stewart explained it in one of the Selenium conf videos.

OP - beware of posts written like this. They're full of rumors and hubris. I've built plenty of frameworks from scratch for both modern React and Angular frontends using selenium. Because I understood what an explicit wait actually did (by looking at the source code, not reading any bs online), I didn't have any of the issues this redditor is talking about. It's a perfectly fine tool for test automation.

Playwright is nice too. My advice would be, don't obsess over the tooling. Either one should get you where you need to be. Focus on scalability, maintainability, elegance, and portability. The tools you use are just one part of the framework.

1

u/OwnVeterinarian9444 Jan 14 '24

ople blame tool. I read the post above and had no clue what they are talking about.

hey! thanks for your answer, please point me to a place where I could read more about how to built a framework from scratch for modern frontends, any tool would be very beneficial, thanks in advance :)

2

u/EVIL_SYNNs Jan 14 '24

Same, some people blame tool. I read the post above and had no clue what they are talking about.

1

u/AncientBattleCat Jan 14 '24

Well, they don't.

A word of caution is to make sure that you do not mix implicit and explicit waits. The main problem is that implicit waits may be baked into the different components that are utilized by Selenium Web driver, all the executables like ChromeDriver.exe, IEDriverServer.exe and so on. Therefore, when you are making multiple hops between the different implicit waits, you can stray into “undefined behavior” (Jim Evans).

And if you got lucky with selenium and you are ok with "test maintenance overhead" that is your choice. For the majority of people running selenium has no benefits. None whatsoever. They end up maintaining miles of in-house code and flaky tests, instead of actually testing application. I don't know who you are to discard anyone. Or you just an old head doing test since selenium took over mercury but you still can't accept the fact that world is moving forward and things should be done in a simple manner. Scalability, maintainability, elegance, and portability - whatever that means.

2

u/hydraBeHailed Jan 14 '24

Having used pure selenium, then nightwatch.js, and then moved to PlayWright when it came out.. I am inclined to agree.

I've migrated 3 projects in different companies from selenium to PlayWright and it was well worth the headache and long hours at first as it made my life easier down the line

1

u/GabrielCliseru Jan 17 '24

you will develop, ok, but in order to improve it and develop tests you will need a colleague.

here are a few questions to ask yourself:

  1. is the cost of your colleague (the brut salary for the company) cheaper than a professional solution?

  2. will your increasing cost of software automation help you when there will be cost cuts?

  3. why do you think you will do a better job than an established company?

  4. if you were your manager, who will maintain your framework after you leave? How happy will you be if you are forced to hire another expensive resource to pick up the effort

no need to reply. We are all passionate about writing stuff but do they actually make sense?

0

u/Mydocalm Jan 14 '24

7. Yes, our architect implemented playwright and created the whole framework with POM as design pattern.

8. and overall answer. This is not something that a senior automation engineer does to be honest. That’s why you are or have an architect. You can’t read articles and be ready. Best way to learn is from someone who is an architect imo.

0

u/[deleted] Jan 14 '24

[deleted]

1

u/Yogurt8 Jan 14 '24

I’ve refined mine to the point of doing POM but just for locators and not abstracting too much interactions.

Out of curiosity, how do you handle performing actions/workflows? What do your tests look like?