If you’re reading this blog post, probably you might have written an automation script but some of the steps are not generating the expected result after performing actions like clicking on a button or setting a text in a textbox even though when UFT can easily identify the required objects, and now you are wondering how to figure out this issue.On the off chance that you are confronting similar issues, you have landed on the right post. The solution to such issues is to use Settings.WebPackage ReplayType in UFT using which we can manipulate UFT Web add-in’s replay type from event to mouse, or vise versa.
Let’s get started!
What is ReplayType in UFT
- Events (ReplayType=1) – This is the default value.Replay of events is done using the Browser methods (similar to DOM).
- Mouse (ReplayType=2) – Replay of events is done using the mouse, and keyboard operations using the keyboard.
When to Use Settings.WebPackage Replaytype 2
There can be any number of scenarios, I am mentioning a few of them
- There might be a scenario where UFT can identify a button or link object but it is not able to click the same during execution.
- Upon manually entering a value to a WebEdit box a Submit button is supposed to be enabled but the same is not getting enabled when a value is set to the Textbox using UFT during execution.
- Upon selecting a value manually from a drop-down “ABC” the corresponding values are supposed to be auto-populated in another drop-down “XYZ”. However, during execution when a value is selected from dropdown “ABC” the corresponding values are not getting populated in the dropdown “XYZ”.
- Any such type of action that works fine manually whereas doing the same action using UFT does not produce the expected result or does not work. In such a scenario, we should use ReplayType mode 2.Upon setting the value of ReplayType to 2, UFT starts performing actions on the web objects in such a way as a real human being is performing those actions.
Difference between ReplayType 1 and 2
If the ReplayType is either Event or 1, at runtime the mouse cursor doesn’t move while clicking a button/link/checkbox/radio button or setting a value to any WebEdit, and the required operation is performed directly through the browser event.
However, if ReplayType is Mouse or 2, the mouse cursor is also moved to the web objects while any action is performed. When the ReplayType is 2 each keyboard and mouse action is performed like a real user.
How to Use Settings.WebPackage Replaytype
You can change the default replay type settings by navigating to Tools >Options>GUI Testing>Web>Advanced. Under this find the ReplayType option and select the desired mode. Having said that, it is advisable to change the ReplayType mode using code and reset its default value that is 1 after fulfillment of the purpose.
Before performing the required action on an object that requires interactions like a real human, follow the below steps:
Step 1: To resolve the issue with the object because of which the problem occurs,change the replay type before the Click / Set / Select operation to Run by mouse operations using.
Setting.WebPackage(“ReplayType”) =2 ‘Set the ReplayType to Mouse
‘Write the code for the required action to be done.e,g clicking a button
Step 2: Reinstate the value of ReplayType after performing the action on the required web object.
Setting.WebPackage(“ReplayType”) =1 ‘Set the ReplayType back to 1.
It is highy recommended to reinstate ReplayType to 1 otherwise, execution time will increase significantly.
Example of Using Settings.WebPackage Replaytype
Setting.WebPackage("Replaytype")=2 'Setting ReplayType to Device(mouse) to perform human like action
Brower("ABC").Page("XYZ").WebButton("Submit").Click 'Submit button requires real user like action
Setting.WebPackage("Replaytype")=1 'Re-setting ReplayType back to default
You can retrieve the current replay mode using the following code:
currReplayMode = Setting.WebPackage(“ReplayType”)
- How to Use Shell Scripting in UFT to SendKeys
- How to Use Recovery Scenario in UFT with Example
- Understand Local And Shared Object Repository in UFT
- 5 Tips for Using External Environment Variables in UFT
- How to Use Call Stack in UFT to Trace Function Calls with Example
- Automation Object Model in UFT One (AOM)
- How To Get Tooltip Text In UFT
- Mainframe Automation Using UFT One
- GetRoProperty , SetToProperty & GetToProperty in UFT With Example
- Read and Update XML File in UFT | VBA