Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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++) {
    print(selenium.getText(css=div[id='unique']>a:nth-child(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
add comment

2 Answers 2

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
add comment

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++) {
    print(selenium.getText(css=div[class='row']>a:nth-child(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
add comment

Your Answer

 
discard

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.