Overview:
Opkey Web allows you to create dynamic objects at runtime. The Dynamic Object is an advanced feature which is very helpful in case you need to create and use multiple objects which have almost similar properties. In such cases, you can use dynamic objects which are used only at runtime.
Why to use Dynamic Objects instead of Object Repository?
It is 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 an FL to click on a button. First of all, you need to record actions, fetch objects, save and execute them in case you are using OR.
While using Dynamic Objects, you just need to inspect elements and provide Xpath as the Dynamic Object Property. The FL will get executed without fetching the required objects.
For More – See Example below:
To add a Dynamic Object, follow the steps given below:
In case you click on the Object Repository or Output radio button then It will not be reflected in the Test Steps unless and until you select the Desired Object Repository or output.
Example:
Test step 1: OpenBrowser
Test Step 2: For
“i” is a output variable which will hold the output of Step2
Test Step 3: StringConcat
This String 2 “i” indicates the variable whose value changes on every iteration
For the First iteration the value of i [String 2] is “1”
Out1 is a output variable which will hold the output of Step3 StringConcat
Test Step 4: Click
Test Step 5: Next
The FL will get executed and Click on the highlighted alphabets [in the screenshot below] one by one from A- Z
Explanations:
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 are almost similar. Hence, we have used Dynamic OR feature for this particular scenario. We have logically made Xpath (as shown above) in such a way that the Xpath changes with each iteration of for loop. This Dynamic Object containing desired Xpath property is passed as an Object input Argument for Test Steps 3, 4.
Thus, when the FL gets executed for the first time, the first value [A] gets clicked. Then Test Step 6 transfers the control back to Test Step 2 with an incremented value of i=2 for the 2nd Iteration.
The process continues for 25 Iterations till the value of i becomes 25. This is how the Test Case gets executed completely.
When the Test Case 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.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article