I am writing a test suit in selenium using java language. I use the TestNG annotations and Maven repository to manage dependencies, currently using Eclipse and the project is hosted on GitLab. I have a set of 40 test cases but my situation is that I need to check them against different pages/URLs.
For Example.
Class A needs to run test cases 1 to 15
Class B needs to run test cases 5 to 35
Class C needs to run test cases 1 to 40
Class D needs to run test cases 15 to 30
Class E needs to run 1 to 8 then 22 to 38
I also want to get your opinion as to how I can check each of the web pages have these elements and then determine which test cases to run respectively.
For now I am repeating my code by copy pasting into each class which is not a good way and I am looking for a more dynamic way to address this issue.
One of my colleagues told me to try to read the API response of each URl and then somehow extract the information from there as to which elements are present on this page and then only run those test cases respectively but I am having hard time grasping this approach.