I have been doing automation for websites and mobile apps since last year. I am using Java,Selenium webdriver, and TestNG.

Now I have one big project to do automation and I would like to first set its proper structure in terms of programming such as packages,utility,classes, etc. and need and expert who can help me here.

Project description is given below :

1 - It is something like find candidates, employers. 2 - Search jobs by consultant team and contact candidates. 3 - Diff. Role there like Admin,HR,Data entry operator,Manager. Every role has diff. permissions like Function which HR can access maybe data entry operator cannot.

So I want to know how I can define an automation structure for it?

I am thinking like :

1 - Create packages of all diff. Roles

2 - Create all global methods in utility package. Ex:login, register

3 - Create methods role-wise as per role packages

4 - There are many diff. modules also.

So in future if any other testers want to continue scripting then they can understand above structure easily and can find particular module code easily.

Can anyone suggest to me things to improve above structure? Or a good model to follow?

2 Answers 2


I'm not sure if you're familiar with the page object model, but you might be interested in it. You create a class hierarchy that resembles the page structure of the site you're testing. This model completely separates the WebDriver code and the TestNG code by creating this page interface that gives tests a universal way to interact with a particular page.

If a web page is simple and has only one state, then it gets one class that contains all it's behavior. If a page is more complex than that, create a smaller page hierarchy where you give an abstract super page object the common attributes all states share. Then split each state or component of that page into it's own sub-classes. With this model, actions on a page that trigger a redirect or state change will return a reference to the page object that represents it. Using this model, your tests can just progress through the chain of actions that travel from page to page.

Try giving this page a look: http://www.guru99.com/page-object-model-pom-page-factory-in-selenium-ultimate-guide.html

Or this official page object example by the selenium team: https://code.google.com/p/selenium/wiki/PageObjects

This model plays well with method chaining, where your page behavior methods which don't redirect or change a page's state can return a reference of itself. This allows you to chain multiple actions back to back in a single statement.

  • Yup , I am familiar with page object model , I thought to use that but just want to confirm here there if there any other structure available...thanks a lot. Jun 8, 2015 at 4:34

I prefer to use a Test Driven Design approach when setting up the frame work. The relevant code needed should just fall into place. I also develop my code based on a pages classes hierarchy. What this means is that each page in my website is represented similarly in the architecture.

  • Can you share a link where I can see perfect example of your approach? Jun 8, 2015 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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