Validation of the mouse

Ranorex Studio, Spy, Recorder, and Driver.
Anett
Posts: 2
Joined: Fri Jan 25, 2019 9:40 am

Validation of the mouse

Post by Anett » Fri Jan 25, 2019 9:53 am

Hello all,

I need to validate in my scipts that the mouse pointer changes to a doubled arrow by moving over a special point.
Is there a possibility for that?

Best Regards,

Anett
Last edited by Anett on Tue Feb 05, 2019 7:49 am, edited 1 time in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Validation of the mouse

Post by odklizec » Fri Jan 25, 2019 1:51 pm

Hi Anett,

There is no built-in way to achieve what you want, so you will most probably have to create some code for this. For evaluating mouse pointer, you can use Mouse.CursorName, which should return name of actually used cursor.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Andymann
Posts: 50
Joined: Wed Jul 27, 2016 12:22 pm
Location: Hamburg
Contact:

Re: Validation of the mouse

Post by Andymann » Fri Jan 25, 2019 3:32 pm

I did that once and my code (which works surprisingly well) looks like this (pSeconds is the amount of seconds that I am willing to wait.):
string currentState = Mouse.Cursor.ToString();			
        	System.Diagnostics.Stopwatch newWatch = System.Diagnostics.Stopwatch.StartNew();
        	
        	while (currentState.ToLower().Contains("waitcursor") && newWatch.Elapsed.Seconds <= pSeconds){
        		Thread.Sleep(1000);
        		currentState = Mouse.Cursor.ToString();
        		//Ranorex.Report.Debug("waitForSavingDone(): currentState=" + currentState + ". newWatch.Elapsed.Seconds:" + newWatch.Elapsed.Seconds + "; pSeconds:" + pSeconds);
        		
        	}
        	        	
        	if(newWatch.Elapsed.Seconds > pSeconds){
        		//Ranorex.Report.Error("Mauszeiger zeigt nach Ablauf von " + pSeconds.ToString() + " Sekunden immer noch 'Speichern'.");
        		throw new TimeoutException("Mauszeiger zeigt nach Ablauf von " + pSeconds.ToString() + " Sekunden immer noch 'Speichern' - Timeout.");
        	}else{
        		Ranorex.Report.Info("Mauszeiger gibt keinen Hinweis (mehr) auf 'Speichern'-Vorgang.");
        	}			

Vorsprung durch Wahnsinn
www.Doktor-Andy.de

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Validation of the mouse

Post by Stub » Mon Jan 28, 2019 11:44 am

I wrote some code to validate the mouse cursor. It was useful in verifying that I'd calculated the correct position for the mouse in our AUT.

I look at Mouse.CursorName first. This works great with system cursors.

But in our case it might be something like "Custom123456" if it's a mouse cursor image of our own. If that's the case then I Ranorex.Imaging.Load() an image of the mouse cursor that I previously saved via Mouse.GetCursorImage(). And then I Ranorex.Imaging.Compare() that loaded image with the current cursor image, via Mouse.GetCursorImage() again.

Anett
Posts: 2
Joined: Fri Jan 25, 2019 9:40 am

Re: Validation of the mouse

Post by Anett » Tue Feb 05, 2019 8:48 am

Thank you very much!!!!

Validating the CursorName is the way we will do it.

Thank you everybody!