Test Structure - How to organize the Selenium Webdriver Java files?


I am new to Appium, Selenium Webdriver, and Cucumber. I am interested to know if anyone can provide on how to organize the Java files so that we can reduce redundancy and promote code reusability? Thank you!

I would suggest just maintain maven directory structure.Like all tests file need to store in test/java directory.
all other resources (properties file, application apk, cucumber feature files) need to be stored in test/resoruces directory.

I have sample appium java project which u can refer for

Priyank Shah

Thank you Priyank! We currently have that separation such as all tests file storing in test/java directory and the rest in test/resources. What I am interested more is the structure inside test/java directory, on how to best organize it in a way where it has a better hierarchy. For instance, does each screen of the mobile app has one library java file which provides all the functions that a test can call to manipulate that screen? ex: AccountScreen.java, CheckInScreen.java, etc… Does this file provide direct link to where the cucumber test file is calling the functions? Or is there another java file that are in between these screen files and the cucumber files?

Our mobile app has many screens, it is getting quite messy when we start putting out codes. Things are everywhere and we just want to find a way to avoid redundancy and promote re-usability codes.


Yes, if you feel some utility or set of functions that u can use across different projects than u can bundeled in one jar.
like for instace.
setText,scrollTo these kind of functions u can use across different files. so u can bundle them.

and regarding cucumber files, U need to create runCucke files which points to ur testNG xml, which eventually trigger your tests.

I will upload cucumber+Appium project soon to my github page.

Priyank Shah