I have a problem when using SendWait(text) to enter a text

Ask general questions here.
mto
Posts: 25
Joined: Tue Jan 06, 2015 10:31 am

I have a problem when using SendWait(text) to enter a text

Post by mto » Wed Mar 07, 2018 10:38 am

Hello all,

I am using "System.Windows.Forms.SendKeys.SendWait(text)" to enter a text in a textbox for example. But i have an issue when entering the text passed in parameter. Sometimes, when i want to enter for example the texte "login", it enters "llogin" with double "l" and i don't understand this problem.

Here is the c# code used to enter text :
public static void EnterText(string text)
{
   Timer.WaitNotBusy();
   Ranorex.Report.Info("Enter text: " + text);
   System.Windows.Forms.SendKeys.SendWait(text);
}
public static void WaitNotBusy(int delay = Constants.delay_verymedium)
// Constants.delay_verymedium = 2000 ms
{
 System.Diagnostics.Stopwatch newWatch = System.Diagnostics.Stopwatch.StartNew();

while (newWatch.Elapsed.Seconds <= delay && Ranorex.Mouse.CursorName.Contains("Wait")) {
    Ranorex.Report.Info("Cursor is:" + Ranorex.Mouse.CursorName);
    Thread.Sleep(50);
   }
}
I call EnterTex() like this :
Common.Utils.UI.Keyboard.EnterText("login");
My question is, why it enters "llogin" instead of "login" ?

Thank you in advance for your herlp

Best regards

MTO

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: I have a problem when using SendWait(text) to enter a text

Post by McTurtle » Thu Mar 08, 2018 2:42 pm

Hi MTO,

I was not able to replicate this.
Does the same happen when you use "Keyboard.Press(text);" instead of "EnterText(text);" ?

Regards,
McTurtle

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

Re: I have a problem when using SendWait(text) to enter a text

Post by odklizec » Thu Mar 08, 2018 2:59 pm

Hi,

Could you please check, what's the actual state of this Ranorex setting:
Use asynchronous dispatching of mouse and keyboard events
It can be found in Settings >> Advanced tab. If enabled, try to uncheck it (or vice versa).

Also, I would suggest to use PressKeys method associated with given repo element, like this:

Code: Select all

repo.ElementName.PressKeys("login");
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

ahoisl
Certified Professional
Certified Professional
Posts: 125
Joined: Fri Sep 07, 2007 8:16 am

Re: I have a problem when using SendWait(text) to enter a text

Post by ahoisl » Thu Mar 08, 2018 9:24 pm

mto wrote:I am using "System.Windows.Forms.SendKeys.SendWait(text)" to enter a text in a textbox for example
This method is not part of the Ranorex framework, but a standard .NET method. So we cannot really give support on that.
Please, as McTurtle already said, use the Keyboard.Press or even better the PressKeys method on an element, because the latter will also set focus to the element.

Regards,
Alex
Ranorex Team

mto
Posts: 25
Joined: Tue Jan 06, 2015 10:31 am

Re: I have a problem when using SendWait(text) to enter a text

Post by mto » Fri May 25, 2018 11:08 am

Thank you Alex.

Your solution solved my problem.

Best regards

MTO