I am having a hard time wrapping my head around how to structure the pages. I have seen it several different ways but mainly from tutorials. My question is that I have a lot of elements and how should I structure those elements to where they are maintainable and follow best practices? The elements below are just for one form. The user fills out the form and then clicks submit. Also if you look at the last method you will see like 20 parameters. This already triggers a code smell in my eyes and should this method be broken down in lets say setEmployeeFirstName, setEmployeeLastName etc....? This class will end up with twice as many web elements as well.
More than 3 parameters is definitely a code smell. I would look to using a container of some kind that I can iterate over, perhaps a Map<WebElement, String>, in combination with a Builder. That is, use a Builder to create the Map, pass the map to createEmployee which just iterates over the Map to do something like this:
Thank You for your response. What about data driven or keyword driven testing for automation? I know that you would provide an @DataProvider annotation and provide the name of the provider but from all the sources that I see is that you need to have the parameters in the method which I did in createEmployee. Also the method that returns the 2dimensional object array with its annotation.
Also is it better to break the createEmployee method up into lets say enterEmployeeName(String userName) or enter enterState(String state)? How is this achieved in data driven or keyword driven testing?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop