Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have heard as well as followed concept of keeping UI objects in external filed (xml or properties files in java). But there are times when I need to keep the objects with in test because I use them dynamically.

For example consider one html table with div having uniquq id. The div could have n number of links. I need to read their innertext. So I would be doing -

for(int i=0; i<=CSSCount(div[id='unique']>a);i++) {


So I have app object available in test class it self, that is - css=div[id='unique']>li:nth-child(i) as I need to iterate through its elements. Is it possible to externalize such app objects also?

share|improve this question

Apart from stuartf's comment, I would suggest an approach where when you want to implement things like "as I need to iterate through its elements" to implement them on a generic method and not inside the Test class so as to reuse it (and then it is dynamic).

share|improve this answer
Yup I do that, in fact I follow page object model and keep page interaction module out side test. – Tarun May 11 '11 at 2:53

What you want to do here is change the approach to finding the object, rather than finding the object by id add a consistent class attribute to the each of the divs that you are interested in and find by class rather than the id attribute.

for(int i=0; i<=CSSCount(div[class='row']>a);i++) {

Then you can place the 'row' attribute or whatever you decide to call it in a external resource file.

Hope this helps!

share|improve this answer
actually I was talking about externalizing entire object that would be - css=div[class='row']>a:nth-child(i) – Tarun May 11 '11 at 2:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.