Micro Focus QTP (UFT) Forums

Full Version: How to chek focus..Need Help...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Well i am going to ask to all abt a very simple problem which i do not know...I have a text box and i have to check whether the focus is in that edit box or not....


Can any one gv me any idea that how can i check this scenario??? NOTE:: The focus is coming as pre filled on that field....So i can not set it before i check it......



Is there any method that i can Use????Need idea on URGENT basis plzzz....


Any idea or suggestion will xtreamly appreciated.....


------------
Thanx.
Why focus is required for that?
Code:
txt=Browser().page().webedit().getROproperty("value")
if len(txt)<>0 then
msgbox 'something is already present'
else Browser().page().webedit().set "new value"
end if
@@--rajpes ::

Thanx a lot for your precious suggestion, but i think u did not undrstnd my requirement....i just need to check whether there is any focus on that particular text box or not....

U hv send me d code of to check the length of value present in text box, n if it is zero then set something....that is not required boss....i dnt have to set any thing....just hv to check d focus is there or not....


By d way i hav find out d solution by doing trial n error method for it to check whether focus is there on any particular text field or not....


Thanx once again.....
Ok please share what solution you have found.how do you check focus on an object
Well, not on an object...i tried it on edit box only....I did not think it would be so simple....

tried d following...

Browser("B").Page("P").WebEdit("WE").GetROProperty("Focus")

It will return 0 or 1...if 1 then focus is present, Else not....


Hope its d permanent solution for every application....Tried it on GWT and its working fine....


Let me know if it is working for all or not.....


-----------
Thanx.
Thats amazing. Though spy doesnot show this property it works fine
Ya i know spy does not show this...Actually i got it by doing trial and error method....I also did not know dat it would work as d permanent solution for me......ha ha...cheers dude......



-----------
Thanx.
Hi Friend i followed the same process what you explained but i am getting blank alert screen. My code is

Code:
Dialog("Login").WinEdit("Agent Name:").Set "Raja"
Dialog("Login").WinEdit("Password:").SetSecure "4f7ac2299a7997511b7dfe107a3fa7a5a10912bf"
Dialog("Login").WinButton("OK").Click

a = window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("Focus")
msgbox a

is any mistake in this?????????????? can you pls share the information.