Page 1 of 1

Key sequence / missing letters

Posted: Mon Sep 10, 2012 5:26 pm
by Florent
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

Re: Key sequence / missing letters

Posted: Mon Sep 10, 2012 5:48 pm
by Ciege
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);
}

Re: Key sequence / missing letters

Posted: Tue Sep 11, 2012 8:19 am
by sdaly
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.

Re: Key sequence / missing letters

Posted: Tue Sep 11, 2012 11:34 am
by Florent
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);
			 }
    }
}

Re: Key sequence / missing letters

Posted: Tue Sep 11, 2012 11:46 am
by sdaly
Change "partial" to "static"....

Re: Key sequence / missing letters

Posted: Tue Sep 11, 2012 11:53 am
by Florent
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)"

Re: Key sequence / missing letters

Posted: Wed Sep 12, 2012 10:46 am
by Support Team
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

Re: Key sequence / missing letters

Posted: Wed Sep 12, 2012 11:00 am
by Florent
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

Re: Key sequence / missing letters

Posted: Wed Sep 12, 2012 1:11 pm
by Support Team
Hi,

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

Regards,
Markus
Ranorex Support Team

Re: Key sequence / missing letters

Posted: Fri Dec 21, 2012 11:51 am
by mdgairaud
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.

Re: Key sequence / missing letters

Posted: Fri Dec 21, 2012 4:01 pm
by Ciege
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.