So, I’m going through the selenium test design considerations documentation and I have a question about the UI Mapping section found here:
http://seleniumhq.org/docs/06_test_design_considerations.html#ui-mapping
They suggest to create a properties file like so:
admin.username = loginForm:tbUsername
admin.loginbutton = loginForm:btnLogin
admin.events.createnewevent = adminHomeForm:_activitynew
admin.events.cancel = addEditEventForm:_IDcancel
admin.events.viewoldevents = adminHomeForm:_activityold
That maps an html object to a keyword
Then they will use it like so:
selenium.type(admin.username, "xxxxxxxx");
However, from what I’ve seen about the Properties Object it works very similar to a hashtable. Now I’m loading my properties file as shown here:
http://docs.oracle.com/javase/tutorial/essential/environment/properties.html
under the create and load default properties section
So todo the same statement in the docs I need todo:
selenium.type(loadedProps.get(admin.username), "xxxxxxx");
which isn’t bad, just not as readable as their example, so my question is how do I load the properties file so I can use the keywords like they do.
Also, I’m thinking about going with Page Object Design Pattern, so if I did go that way, would I define a PageObject Base class, which loads
the properties file and then all the page object classes that extends the base will have access to the properties, is this sound reasoning?
in java, since ‘.’ has meaning as an operator, you can’t make it look exactly like their example (not sure what they were getting at). you could do something like:
setup code:
usage code:
if you really got crazy, you could load the Config class using reflection (to remove the boilerplate in the “static” block).