While doing automation, we could have come across the fields which will do the functionality like,
1. While entering some text, it will auto populate the matching values
2. While entering the text, it will mask the values i.e. convert to xxx.. or ....
To simulate the functionality many of us could have faced problems while entering the values on the field;
How to handle such controls effectively. Here we go;
1. WScript.Sendkeys
The important thing here, always have focus on the current window before passing sendkeys.
2. BLUR
You can call the blur event after entering the values in the field like;
May be both the approaches will fail or should be better approaches out there, please feel free to share with us.
1. While entering some text, it will auto populate the matching values
2. While entering the text, it will mask the values i.e. convert to xxx.. or ....
To simulate the functionality many of us could have faced problems while entering the values on the field;
- The value entered is not converting as masking text as it is doing while manual flow
- The form not accepting the entered values
- The entered/selected value not persists in the field after the simulation, etc.
How to handle such controls effectively. Here we go;
1. WScript.Sendkeys
Set shell = CreateObject("Script.Shell") Window("hwnd:=" & Browser("myApp").GetROProperty("hwnd")).Activate 'if it's Browser obj.Set "" Wait 1 obj.FireEvent "OnFocus" Wait 1 shell.SendKeys "your value", 1000 Wait 1 shell.SendKeys "{TAB}"
The important thing here, always have focus on the current window before passing sendkeys.
2. BLUR
You can call the blur event after entering the values in the field like;
Set shell = CreateObject("Script.Shell") Window("hwnd:=" & Browser("myApp").GetROProperty("hwnd")).Activate 'if it's Browser obj.Set "" Wait 1 obj.FireEvent "OnFocus" Wait 1 shell.SendKeys "your value", 1000 Wait 1 obj.Object.blur 'OR obj.FireEvent "OnBlur"
May be both the approaches will fail or should be better approaches out there, please feel free to share with us.
Comments
Post a Comment