Key sequence / missing letters

Bug reports.
User avatar
Florent
Posts: 67
Joined: Wed Jul 04, 2012 3:31 pm
Location: Amiens / France

Key sequence / missing letters

Post by Florent » Mon Sep 10, 2012 5:26 pm

Hi Support Team again,

Sometimes, when Ranorex runs in the turbo mode, some key sequences recorded are not completely reproduced. A few letters are missed at the begining or at the end of the sequence. Is it because of the turbo mode. If yes, is it possible to execute one step with the normal speed when all the scenario is executed with the turbo mode.

Thank you in advance.
Best regards,
Florent

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Key sequence / missing letters

Post by Ciege » Mon Sep 10, 2012 5:48 pm

You can write your own little method that will enter keystrokes at a predetermined speed...

for example the following will wait 1 second between each character typed:

Code: Select all

string strMyString = "This is my string";
foreach (char c in strMyString)
{
  Keyboard.Press(c);
  Thread.Sleep(1000);
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Key sequence / missing letters

Post by sdaly » Tue Sep 11, 2012 8:19 am

This may be of interest - http://soft-test-tech.co.uk/2011/09/robust-data-input/

The idea is to validate the field after entering to ensure it contains the desired input, if not, re-enter again - just like a human would.

User avatar
Florent
Posts: 67
Joined: Wed Jul 04, 2012 3:31 pm
Location: Amiens / France

Re: Key sequence / missing letters

Post by Florent » Tue Sep 11, 2012 11:34 am

Thank you both,

I'm trying the second solution of sdaly. I've got the following error message : "Extension method must be defined in a non-generic static class (CS1106)". All attemps i try to define a non-generic static class fails. Do you know what's wrong with the code below ?

Code: Select all

namespace Scenar1.Scenario1
{
    public partial class Code_tests
    {
        private void Init()
        {
        }
        	public static void CodeKeySeq(this Ranorex.InputTag inputTag, string text)
	        {
				int attemptsToSetField =0;
				int maxAttemps = 20;
				string rxPath = inputTag.GetPath().ToString();
	
				while (inputTag.TagValue != text) 
				{
				//Report.Log("Trying to set text field.  Current value is"+ inputTag.TagValue);
				inputTag = rxPath;
				inputTag.TagValue = "";
				inputTag.Click();
				inputTag.PressKeys(text);
				Thread.Sleep(1000);
				attemptsToSetField++;
				
				if (attemptsToSetField >= maxAttemps)
					{throw new Exception("Could not set text in input tag");}
				}	
				//Report.Log("Input tag set ok, value is" + inputTag.TagValue);
			 }
    }
}

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Key sequence / missing letters

Post by sdaly » Tue Sep 11, 2012 11:46 am

Change "partial" to "static"....

User avatar
Florent
Posts: 67
Joined: Wed Jul 04, 2012 3:31 pm
Location: Amiens / France

Re: Key sequence / missing letters

Post by Florent » Tue Sep 11, 2012 11:53 am

i've already try that but it's does not work :

"Missing partial modifier on declaration of type 'Scenar1.Scenario1.Code_tests'; another partial declaration of this type exists (CS0260)"

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Key sequence / missing letters

Post by Support Team » Wed Sep 12, 2012 10:46 am

Hi,

You are getting this error because your static method is not in a static class and you cannot change partial to static if you copied it to the UserCode part of a Recording file.
You have to create a static class and then you can use the specific method, as mentioned on the specific blog.

Regards,
Markus
Ranorex Support Team

User avatar
Florent
Posts: 67
Joined: Wed Jul 04, 2012 3:31 pm
Location: Amiens / France

Re: Key sequence / missing letters

Post by Florent » Wed Sep 12, 2012 11:00 am

Support Team wrote:Hi,
You have to create a static class and then you can use the specific method, as mentioned on the specific blog.
Hi Markus,

i've tried that yesterday and i had not error messages from the compiler but when i created a user-code action, the specific method was not visible in a combo box of available methods. I will try again soon

thx

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Key sequence / missing letters

Post by Support Team » Wed Sep 12, 2012 1:11 pm

Hi,

Maybe the following forum post is also useful for you: Code module in recording module.

Regards,
Markus
Ranorex Support Team

mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

Re: Key sequence / missing letters

Post by mdgairaud » Fri Dec 21, 2012 11:51 am

Hi,

If it's a textbox I always assign value instead of 'typing' it, it always works (at least on web pages)

repo.MyPath.MyElement.Value = "value";

Regards,
Mateo.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Key sequence / missing letters

Post by Ciege » Fri Dec 21, 2012 4:01 pm

mdgairaud wrote:Hi,

If it's a textbox I always assign value instead of 'typing' it, it always works (at least on web pages)

repo.MyPath.MyElement.Value = "value";

Regards,
Mateo.
This works fine, usually...

If you AUT happens to have a fire event that is triggered by the element, then setting the value directly will result in this fire event not being triggered as expect which could then result in your AUT not behaving the way you expect it to. Be very sure you know that your element does not have an event tied to it if you plan on continuing with this method of setting the value.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...