• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Java + Selenium + TestNG Design Question

 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Sheriff
Posts: 16669
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic