Single line code for multiple objects(of same typ)
In real-time, is it possible to have only one line of code for many objects (belong to the same class/type).
For each type of object, only one line of code would be written, like the below:
Browser().Page().WebEdit("name:=" & oname).Set oval
In the above, we pass the field name(oname) and field variable in a variable(oval).
This pair will be in the test case, this will be fetched as a single string, and will be later split and
placed into an array.
We "For" loop it until the UBound of this array.
Is this doable practically. I was asked this question in an interview and my answer was the above one.
The architecture is:
Page-wise functions / actions
In each function, just 5/6 lines of code, even though
there are 40 objects and in 5/6 types.
If there are 40 edit boxes in a single page,
can we just use the SETTOproperty for filling all these.
By using this, we can make qtp fill that specific edit box by setting the name property
of each edit box (using settoproperty)
Re: Single line code for multiple objects(of same typ)
What u could do is create a function that can accept the property name, attribute value and index if you wish to for each object type. U can then build a string based on these and use it for various objects of same type.
For question 2:
Ensure atleast one edit box is added to the repository, so u can configure the properties for the other editboxes at runtime using setToProperty.