HasFocus property not working

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Rakesh123
Posts: 63
Joined: Thu Oct 28, 2010 2:18 pm

HasFocus property not working

Post by Rakesh123 » Wed Nov 06, 2013 12:30 pm

Hi

I have a sceanrio where I need to verify whether the cursor focus is on paticular textbox or not.
So for this I tried using 'HasFocus' property of the object but it is displaying result as 'false' for both the conditions.

Can we have any other way to verify the cursor focus is on particular object or not?

Thanks,
Rakesh

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: HasFocus property not working

Post by Support Team » Thu Nov 07, 2013 2:45 pm

Hi,
Rakesh123 wrote:Can we have any other way to verify the cursor focus is on particular object or not?
Would it be possible to post us a Ranorex Snapshot of this control using the "SCROLL" key snapshot.
To get the correct snapshot please open your application and open Spy. Now instant track the control you want and then press the scroll key on your keyboard.

Thanks in advance.

Regards,
Peter
Ranorex Team
.
Image

Rakesh123
Posts: 63
Joined: Thu Oct 28, 2010 2:18 pm

Re: HasFocus property not working

Post by Rakesh123 » Sat Nov 09, 2013 7:55 am

Hi Peter,

As u have asked for the snap shot.I am sending the snapshot.

Please reply me ASAP.

As this is some show stopper for one of my test case. :)

Thanks
Rakesh
Attachments
Textbox.rxsnp
(35.85 KiB) Downloaded 161 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: HasFocus property not working

Post by Support Team » Mon Nov 11, 2013 4:54 pm

Hello Rakesh,

Do you get the correct value in Spy?
According to your snapshot, the following Text seems to have the focus:

Code: Select all

/form[@title='Patient Search']/text[5]
Please let me know which TextBox do you want to validate.
Do you perform a mouse-click on your TextBox?

Regards,
Markus (T)
.
Image

Rakesh123
Posts: 63
Joined: Thu Oct 28, 2010 2:18 pm

Re: HasFocus property not working

Post by Rakesh123 » Tue Nov 12, 2013 6:05 am

Hi Markus,

I think that I have send you the wrong attachment.

Please find the attached snap shot where I am facing the problem.

I have also attached my application snap shot where I am facing this problem.

Following are the details about the application..
---------------------------------------------------------
1.Technology:Delphi
2.OS:Windows 7

Thanks,
Rakesh


Thanks,
Rakesh
Attachments
Application.JPG
Application Snap Shot
Application.JPG (70.17 KiB) Viewed 1647 times
Textbox.rxsnp
Ranorex Snap Shot
(30.13 KiB) Downloaded 131 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: HasFocus property not working

Post by Support Team » Wed Nov 13, 2013 5:09 pm

Hello Rakesh,

How do you verify if an element has the focus?
Do you use something similar to the following code:
Report.Info("Focus: " + repo.FormVipApplication.FirstName.HasFocus);
Regarding your snapshot, no element has the focus.
This could happen during saving a snapshot since Spy takes over it.

Please describe all your steps that you did.
This would help us to reproduce it on our system.

Regards,
Markus (T)
.
Image

Rakesh123
Posts: 63
Joined: Thu Oct 28, 2010 2:18 pm

Re: HasFocus property not working

Post by Rakesh123 » Thu Nov 14, 2013 5:45 pm

Hi,

Below is the process how I used to check the has focus property..

1.Open the application i.e 'Patient Search' screen(Screen shot mentioned below)
2.Place the cursor in textbox i.e 'Last Name textbox in 'Patient Search' screen
3.Track the object(Last Name textbox).
4.Check the details tab in Ranorex Spy.

While doing this "HasFocus' property is displaying false value

Thanks,
Rakesh

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: HasFocus property not working

Post by krstcs » Thu Nov 14, 2013 6:00 pm

If you click off of the item, into Spy for example when you "Track", then that item will not have focus, Spy will have focus. So, this appears to be working as expected/intended.

Maybe the question should be, why do you need to validate that the text box has focus when you just clicked it? If you are actually entering data into the field and it doesn't have focus, that step should fail anyway.

Maybe you can explain your test case a little more and we can help you figure you out the best way to approach it?
Shortcuts usually aren't...

Rakesh123
Posts: 63
Joined: Thu Oct 28, 2010 2:18 pm

Re: HasFocus property not working

Post by Rakesh123 » Sat Nov 16, 2013 10:25 am

Hi,

No the test case is not like click on the textbox & validate.

Actually we need to change some settings in the application & then we need to verify that as per that setting the focus is on the particular textbox or not.

Ok,What you said may be correct like when we click on track button in Ranorex spy may be the focus is shifted to Ranorex spy.

I will just check it out let you know whether it is working or not.

Thanks,
Rakesh