OpKey Test Accelerator allows you to create dynamic objects at run time. The concept of dynamic Object is introduced for the situation when you need to create and use multiple objects having almost similar properties. In this case, instead of creating multiple objects, we use dynamic objects which are used only at runtime.
Why to use Dynamic Objects instead of Object Repository?
Its true that the Test scripts can be executed both with Object Repository (OR) and Dynamic Objects. However, Dynamic Objects have several advantages over OR.
Suppose you need to create a Business Component to click on a button.
While using Dynamic Objects, you just need to inspect element and provide Xpath as the Dynamic Object Property. The Business Component will get executed.
For More – See Example[ Given below]
To add a Dynamic Object, follow the steps given below.
- Select any Test Step whose action requires an Object Input Argument.
- Click on the Object Input Argument icon .
- Click on the Dynamic Object icon .
- A Dynamic Object window will get open at the bottom of the screen.
- Add Property allows you to add any property of the dynamic object.
–You can select any property for which you want to provide value. Suppose you have provided values for properties like Logical Name, Name, Innertext, id, class and tag.
In this case, OpKey Test Accelerator will take the property which has the highest priority as Dynamic Object Property.
*The priority of the object properties are set internally in OpKey Test Accelerator in the following order:
- Delete Property allows you to delete any selected property of the dynamic object.
- Select any property for which you want to provide value. Click on the Value cell.
If you wish to provide the Property value through Data Input then click on the Data Input Icon. The list of all Data Input Parameters will get displayed along with their Data Type and Description. Just click on the specific Data Input you wish to provide as Property Value. The selected Data Input will get added as the Property Value.
If you wish to provide the Property value through Data Output then click on the Data Output Icon. The list of all Data Output will get displayed along with their Output Variable Name and Description.Just click on the specific Data Output you wish to provide as Property Value.The selected Data Output will get added as the Property Value.
- If you wish to provide the Property value through Global Variable then click on the [Global Variable ]Icon. The list of all System_Defined and User_Defined Global Variables will get displayed along with their Data Type and Value .Just click on the specific Global Variable you wish to provide as Property Value.The selected Global Variable will get added as the Property Value.
- Click on Save.
Let us consider the following Example to understand the concept of Dynamic OR
With reference to the screenshot given below, consider the following Test Steps of an Business Component :
Test step 1: OpenBrowser
Test step 2: For
“i” is an output variable which will hold the output of Test Step 2
Test step 3: String Concat
This String 2 “i” [which is the Output of Test Step 2 indicates the variable whose value changes on every iteration]
For the First iteration the value of i [String 2] is “1“
Out1 is an output variable which will hold the output of Test Step 3 “StringConcat”
Test step 4: Click
Test step 5: Next
The Business Component will get executed and Click on the highlighted alphabets [in the screenshot below] one by one from A- Z.
Since a single value is provided for the Test Step 1, only 1 iteration will be performed for the Test Step 1. So in this case, Test Step 1 will be executed and will open the given URL on the specified browser. Once the execution is completed for Test Step 1, the control moves to Test Step2 which creates a For Loop with an incremental variable i having initial value 1.
Now, Test Step 3 and 4 will get executed with the initial value of i=1. The Xpath property for all the alphabets highlighted in the screenshot has almost similar Xpath property except a part of Xpath which keeps on changing incrementally with every object.
Hence, we have used Dynamic OR feature for this particular scenario. We logically made Xpath (as shown above) in such a way that the Xpath is created for the next object, with each iteration of the for loop. This Dynamic Object containing desired Xpath property is passed as an Object input Argument for Test Steps 3, 4.
Thus, when the Business Component gets executed for the first time, the first value [A] gets clicked. In next Iteration, the value of i changes to 2 and the Xpath is created accordingly, the second value[B] gets clicked. The process continues for 25 Iterations till the value of i becomes 25. This is how the Business Component gets executed completely.
When the Business Component is executed, the execution takes place as follows:
Test step 1:
Iteration 1: Opens the given URL on the specified browser.
For the Test Step 2, 3, 4, 5
And so on till 25 Iterations are completed.
This is the complete Working of Dynamic Objects in OpKey Test Accelerator.