Handling dynamic objects in test automation

In a given test case, objects are components of an application on which you perform an action. Each object has a unique property or attribute, such as name, Xpath, CSS, Tags, etc. 


Based on the nature of these properties, objects are categorized as static, dynamic, or runtime objects. The properties of a static object remain constant with time. However, a dynamic object changes its properties with time or due to external actions such as clicks or mouse hover. Web forms and product listings are examples of dynamic objects.

Runtime objects are generated during run time and hence, have a unique property. For example, order ID of a product purchased on an e-commerce website is a runtime object.

Opkey identifies and fetches these object properties during test case creation. This helps the tool locate these objects on the test page and perform actions on them during test execution. However, test executions often fail when the properties of dynamic objects change or a new runtime object is generated during execution.

Let's go through the methods we can use to capture these dynamic and runtime objects to ensure successful test execution.


1. Using Object repositories to store objects

Opkey enables users to create object repositories (OR). The objects can be captured with their multiple properties such as name, Xpath, CSS, and tags in an OR. 


During test case execution, data related to object properties can be fetched from the repository. So, even when an object property changes, Opkey can still identify the object using the other unchanged properties and execute the test case.

Opkey Spy recorder is used to fetch object properties from web pages and store them in an object repository. Let's go through to steps to create an object repository and store objects in it with Spy Recorder. 

1.  On your project workspace, select a folder for which you want to create a new object repository.


 2. Right click on the folder, hover over Create New, and select the Test case option.



3. Click the Recorder icon at the top of your empty test case and select Web recorder.



4. On the Web Recorder page, choose the Default Object Repository option. it will create an object repostiory for your folder where you can store dynamic objects. After this, click the Start Recording button at the bottom.


5. An Opkey Recorder window with a default browser will open. Select the Spy tab on the Recorder window.


6. Open the URL where want to capture object properties in the browser.


7. Now, Press ALT key on your keyboard and hover over the element whose object you want to capture. For example, we have captured the object properties of the Sign Up for Free button.
We can see that various object properties associated with the button are captured in the Recorder window.


8. Click the Add Object icon on the Recorder to add these properties to the object repository of our folder.


9. Close the Recorder window, and open the default object repository in your folder. You can see the object properties are added.


Now, we can map this object repository to a test case where this object needs to be executed.


2‍. Handling dynamic objects generated at runtime

Opkey has specific keywords that handle runtime-generated objects like the order ID explained in the example above. One such keyword is String_Concat which can capture the newly generated object property in a test step and pass it as input to the next step to validate. Using this keyword, even a unique object ID can be captured and validated successfully. 

To learn more about the uses of such keywords, Click here.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article