I'm working on UI automating testing, using POM with Python and Selenium. I want to know how to handle duplicate test cases.
For example, you have two webpages: Login page and Homepage. I want to test three test cases.
- Homepage functions without login: test_homepage_before_login.py
- Login with valid/invalid username and password: test_login.py
- Homepage functions with login: test_homepage_after_login.py
(1 and 3 have a lot in common. 3 has additional functions. 1 is subset of 3)
There are three files for each test case, and I already implemented 1 and 2. But for the third one, I just imported relevant functions from 1 and 2 modules.
The thing is validating login is duplicate. In this case, do you do login validation every time? Also do you give order or dependency when automating these cases by using pytest-ordering or pytest-dependency?
Another case I can think of is "logout". When you automate logout function, you need to log in first. In this case, do you add login validation beforehand again and implement logout? Do you give dependency in this case as well or just make scripts independent?
Thank you in advance.