I am into the automation of a web application using Selenium. I write test cases without hard-coding anything in the test cases. There were many invalid failures in the run due to GUI changes such as page title change. I moved the page title verification to separate modules that are reused and called by many test cases so that I do not need to fix all the test cases but only few modules.
But I can see that there are around 10 modules that I need to fix in the last minute due to these changes. As a solution I declared and assigned these GUI element identifiers as global variables in a file inside config folder and reuse it in the modules.
My question is: is there any better approach / way to solve this problem? Is there any tool to effectively maintain and organize these global variables since there would be thousands?
Pseudo-code of my solution:
Global variable declaration in a separate file in config folder:
public class globalVariable
{
public final String HOME_PAGETITLE = "Welcome to Home page";
.........
}
Modules calling it:
public class module
{
//Instantiate globalVariable class to use it's variables in module
globalVariable test = new globalVariable();
@Test
public void testHome()
{
//Call the global variable declared
String strExpectedPageTitle=test.HOME_PAGETITLE;
//Verify page title
assertEquals(Selenium.getTitle(),strExpectedPageTitle);
}
}