ExtWebDriver contains a properties fetcher that allows for parameterization of any value. Files that GUIProperties reference will generally contain any locators such as CSSSelectors or XPaths.
my.locatorkey.1 = //div[@id="eevee"]
my.locatorkey.2 = {0}/input[@id="lightningStone"]
my.locatorkey.3 = {0}/div/{1}
Below are a few examples on how to utilize the GUIProperties class.
//Instantiate an object on the properties file which needs to be a resource of the project
GUIProperties gp = new GUIProperties("my-xpaths.properties");
Get the value from properties file given the key:
String example1 = gp.getPropertyValue("my.locatorkey.1");
//example1 = //div[@id="eevee"]
Get the value from properties file given a key and a parameter:
String example2 = gp.getPropertyValue("my.locatorkey.2", example1);
//example2 = //div[@id="eevee"]/input[@id="lightningStone"]
String example3 = gp.getPropertyValue("my.locatorkey.2", "foobar");
//example3 = foobar/input[@id="lightningStone"]
Get the value from properties file given multiple parameters:
String example4 = gp.getPropertyValue("my.locatorkey.3", example1, example2);
//example4 = //div[@id="eevee"]/div//input[@id="lightningStone"]
String example5 = gp.getPropertyValue("my.locatorkey.3", "foo", "bar", "asdf");
//example5 = foo/div/bar
Alongside the single file accessing GUIProperties class, there is a class that allows for multiple files to be searched for properties. You can achieve this by the GUIHierarchyConcatenationProperties class!
my.locatorkey = //div[@id="jolteon"]
my.locatorkey = //div[@id="flareon"]
my.locatorkey.extra = //div[@id="vaporeon"]
Get the value from properties file given a key and a parameter:
GUIHierarchyConcatenationProperties gcp = GUIHierarchyConcatenationProperties("file-1.properties","file-2.properties","file-3.properties");
String val1 = gcp.getPropertyValue("my.locatorkey");
//val1 = //div[@id="jolteon"]
String val2 = gcp.getPropertyValue("my.locatorkey.extra");
//val2 = //div[@id="vaporeon"]