Micro Focus QTP (UFT) Forums
How can I know that Cursor is positioned in a particular field or not - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How can I know that Cursor is positioned in a particular field or not (/Thread-How-can-I-know-that-Cursor-is-positioned-in-a-particular-field-or-not)



How can I know that Cursor is positioned in a particular field or not - PrabhatN - 06-16-2010

Hello All,

I have to test an application where the requirement is as follows:

I have some fields(WebEdit, WebList etc.) and a Submit button in a Submit Report page. Here few fields are mandatory. Means if I leave a mandatory filed blank and click on the Submit button, a window pops up with some warning message. When I click on the OK button in the PopUp Window, cursor is positioned in that mandatory field and this process goes on untill I fill all the mandatory fields up.

Now I want to check this for all mandatory fields. (To validate whether Mandatory option works or not)

Suggest regarding how this can be done........


RE: How can I know that Cursor is positioned in a particular field or not - Jackomcnabb - 06-16-2010

You can get a property from that field, do a spy on that filed and see if you have a unique one and then you can get the value from that field with a GetTOProperty


RE: How can I know that Cursor is positioned in a particular field or not - PrabhatN - 06-16-2010

I had asked how to know whether the cursor is positioned in a particular field or not. So there is no property specified from which u can know it.

@You can get a property from that field : This meant what. Any Property will do ? Smile

@GetTOProperty: This is nowhere related,it should be GetROProperty


RE: How can I know that Cursor is positioned in a particular field or not - Jackomcnabb - 06-16-2010

For example: if you get the title of the field and then if not what expected then it would fail


RE: How can I know that Cursor is positioned in a particular field or not - Saket - 06-17-2010

get 'focus' property using GetROProperty method. returns '1' if object has focus else '0'.

for example if you have to verify a mandatory fields (say "Name") gets focus or not after the warning message. you can use somethine like

Code:
chkFocus =  Browser(" ").Page(" ").WebEdit("Name").GetROProperty("focus")

similarly you can check this for all mandatory fields.
let me know if this helps.


RE: How can I know that Cursor is positioned in a particular field or not - PrabhatN - 06-17-2010

Thanks a lot Saket. It really solved my purpose.

I want to ask you a question. I used to think that we can only get the properties of any object by GetROProperty() method, which are shown under the Identification Properties when that Object is spied. But there is no "focus" property under Identification Properties. But still we can get that.

That being said, Are there any more properties which are not shown in "Object Spy" window under Identification Properties option, but still their value can be retrieved. If yes then can u please enlist few.


RE: How can I know that Cursor is positioned in a particular field or not - Saket - 06-17-2010

basically, you can get all the runtime properties as well using GetROProperty as name suggest RO - runtime objects for objects depending on object type
its not possible for me list out the properties now, but I will definitely try to prepare one for you.


RE: How can I know that Cursor is positioned in a particular field or not - PrabhatN - 06-17-2010

Thank you Saket.....