-2

We are implementing automated testing from scratch and we want to use the Python language.

We want to build all the tests, based on Selenium (Acceptance tests), in a project separate from the main one because we consider that it would have a better maintenance and because the project to be tested is written in Java (Spring) and Angular.

My questions

  1. How to structure or architect a test project with Python?
  2. How would the folders for this project be organized?
  3. What tools are most recommended?
  4. Is my thinking about creating a specialized project for testing wrong?

PS .: I have a developer background and I'm migrating to the automated testing area.

2
  • 1
    You are asking for Best Practices. And best practices don't exist - only good practices in context. (context-driven-testing.com). If there was One Architecture to Rule Them All, there would be no people working on software architecture, it would be a closed topic. I suggest closing this question in favor of a question about tangible and specific problems where one can analyze pros and cons, inside the context where the software will be used. – João Farias Feb 12 at 0:09
  • Thanks for answering! Sorry but I didn't understand what you meant. Anyway, Sameer Jain and PDHide users answered what I needed. I believe that the answers will be very useful for people, like me, who are without a direction. – Iago Frota Feb 12 at 0:38
0

POM: Page object Model:

Arrange the page related actions in respecive classes eg: all login page actions,elements etc in the loginPage class. This helps in easy maintainability and DRY code.

https://www.selenium.dev/documentation/en/guidelines_and_recommendations/page_object_models/

The Page Object Design Pattern provides the following advantages:

There is a clean separation between test code and page specific code such as locators (or their use if you’re using a UI Map) and layout. There is a single repository for the services or operations offered by the page rather than having these services scattered throughout the tests.

DRY:

Don’t Repeat Yourself (DRY) is a software development principle, the main aim of which is to reduce repetition of code

So page object ensures that your code follows DRY code principle.

Avoid proliferation of classes

https://flylib.com/books/en/4.425.1.31/1/

https://courses.cs.washington.edu/courses/cse403/13au/lectures/08-classdiagrams.ppt.pdf

This is a case that caused by creating unnecessary classes that inturn causes maintainance heading. You don't want to make your framework to look complicated just to make others think its a engineering marvel.

Engineering design marvel is to create something simple to use but highly functional , so focus on your scope of testing and the users , than how to make it complicated

Eg: don't need to add elements in a separate class , and then call it in page object , and then abstract it with higher level keywords etc when you really don't have to . But if it makes the life of people who uses it easier, then don't hesitate also.

KISS (Keep It Simple Stupid)

https://medium.com/better-programming/kiss-dry-and-code-principles-every-developer-should-follow-b77d89f51d74

When a program grows in size, the complexity of the code tends to increase. This would give you a hard time debugging, as debugging complex code is a gruesome task. Nobody loves to maintain complex code. This principle states that you should always keep your code simple. If you have a complex piece of code, always try to break it into smaller more maintainable code.

Ensure proper html reporting

Your framework should have proper reporting, this will help in easy debugging. IT should have screenshots and stack trace.

THere is no need for special logger , you can just redirect error and output to a text file .

Promote data driven testing

This is a continuation of DRY principle, you can use the same code to test different scenario using data drivern approach without writing any additional code . THis allows helps in additional coverage.

Simple project structure

pageobjects : page object classes testscripts : ACtual automation test cases reports : Folder where report is generated datafile : File for data driven testing , files like drivers etc

in some frameworks you need to override listner classes to create report so in that case you can create a separate folder:

listners : listner classes

Thats it , you are ready to go

1
  • 1
    Please add a comment when downvoting , let your vote be helpful for someone looking forward to learn something new. – PDHide Feb 12 at 0:14
2

If you are deciding to use better reusability in selenium-python, following are my experience based recommendations which are touch based with ISTQB Test Automation Best Practices:

How to structure or architect a test project with Python?

Better to follow generic Test Automation Architecture while building the repository: https://engineers-hub.teachable.com/courses/istqb-advanced-level-test-automation-engineer-professional-training-with-q-a/lectures/24870027

How would the folders for this project be organized? Reusable functions are the better way of dealing with frameworks in long run.

Reference: https://github.com/spyoungtech/behave-webdriver

What tools are most recommended? Some useful ones to refer:

  • Robot
  • PyTest
  • Unittest
  • DocTest
  • Nose2
  • Testify

Is my thinking about creating a specialized project for testing wrong? Your choice of programming language for automation framework is bit misleading according to my experience. If your application code is written in JAVA, it is highly recommended to write selenium-java to match the JAR files instead of going for isolated .py based framework. (may be there are more advantages to go for selenium python framework)

2
  • Thanks for responding and for the suggestions! In your view, what is the possible problem of choosing your own test project? – Iago Frota Feb 12 at 0:30
  • 1
    There is no relationship between the backend code and the code Language you use for test automation you can use java , python or what ever you want. Tools like protractor helps in handling asynchronous nature of angular project for there than that you can use any language . Everyone recommends to use same language as backend because even developers can pitch into test automation when needed . – PDHide Feb 12 at 7:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.