c# - sendKeys : decimal number

45 views
Skip to first unread message

Nortier David

unread,
Jan 29, 2026, 9:20:06 AM (9 days ago) Jan 29
to seleniu...@googlegroups.com

Hello

 

In an input field “amount” :

 

                IWebElement amountElement = this.webDriverFactory.FindElement(How.Id, "amount");

this.webDriverFactory.MySendKeys(amountElement, this.theTest.User.Transfer.Amount.ToString(new CultureInfo("fr-FR")));

amountElement.SendKeys(Keys.Tab);

 

and:

        public void MySendKeys(IWebElement element, string infos)

        {

            this.ScrollToElement(element);

            element.Click();

            element.SendKeys(infos);

        }

 

 

with a decimal number: e.g., 2.10

 

Sometimes, the entered number is 210

 

I don’t know why …

 

 

If you know 😊

 

 

  David

 

 

 


====== DISCLAIMER ======

https://www.cph.be/maildisclaimer

SuperKevy

unread,
Jan 29, 2026, 1:35:28 PM (9 days ago) Jan 29
to Selenium Users
Is the variable info as string?   Copilot says...
  1. Numbers must be passed as strings

    • sendKeys() accepts CharSequence..., so you need String.valueOf(number) or "12345".
  2. Clear before sending

    • Use clear() to avoid appending to existing text.
  3. For <input type="number"> fields

    • sendKeys() still works, but ensure the value matches the allowed format (e.g., no letters, correct decimal separator).


Nortier David

unread,
Jan 30, 2026, 2:25:03 AM (9 days ago) Jan 30
to seleniu...@googlegroups.com

Hi

 

Thanks for reply.

 

  1. It’s a string
  2. Nothing in the field before sendKeys
  3. What's strange is that it works most of the time.

And sometimes, the amount is 100 times too high, as if it doesn't take the decimal point into account. Probably a cultural issue.

But why not always then?

 

 

 

De : seleniu...@googlegroups.com <seleniu...@googlegroups.com> De la part de SuperKevy
Envoyé : jeudi 29 janvier 2026 19:35
À : Selenium Users <seleniu...@googlegroups.com>
Objet : [selenium-users] Re: c# - sendKeys : decimal number

 

ATTENTION : cet e-mail provient d'une personne externe. Vérifiez toujours l’expéditeur avant d’ouvrir les pièces jointes ou de cliquer sur les liens.

Is the variable info as string?   Copilot says...

1.   Numbers must be passed as strings

    • sendKeys() accepts CharSequence..., so you need String.valueOf(number) or "12345".

2.   Clear before sending

    • Use clear() to avoid appending to existing text.

3.   For <input type="number"> fields

    • sendKeys() still works, but ensure the value matches the allowed format (e.g., no letters, correct decimal separator).

 

On Thursday, January 29, 2026 at 8:20:06 AM UTC-6 n...@cph.be wrote:

Hello

 

In an input field “amount” :

 

                IWebElement amountElement = this.webDriverFactory.FindElement(How.Id, "amount");

this.webDriverFactory.MySendKeys(amountElement, this.theTest.User.Transfer.Amount.ToString(new CultureInfo("fr-FR")));

amountElement.SendKeys(Keys.Tab);

 

and:

        public void MySendKeys(IWebElement element, string infos)

        {

            this.ScrollToElement(element);

            element.Click();

            element.SendKeys(infos);

        }

 

 

with a decimal number: e.g., 2.10

 

Sometimes, the entered number is 210

 

I don’t know why …

 

 

If you know 😊

 

 

  David

 

 

 


====== DISCLAIMER ======

https://www.cph.be/maildisclaimer

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/80966909-2324-4f31-91ee-32a4ee6cc1dcn%40googlegroups.com.

SuperKevy

unread,
Jan 30, 2026, 5:46:33 PM (8 days ago) Jan 30
to Selenium Users

Well, let's assume a JavaScript function is scanning input character by character for non-compliant text (ie. a-z$%&#* etc.).
There is probably some latency in the js execution causing skipped characters.  
Not a problem.  Break the input string into a character string with a delay between each keystroke.
You'll find many examples on the web.
Have fun with that.

Nortier David

unread,
Feb 2, 2026, 2:55:39 AM (6 days ago) Feb 2
to seleniu...@googlegroups.com

Thanks for idea

 

I’ll try

 

De : seleniu...@googlegroups.com <seleniu...@googlegroups.com> De la part de SuperKevy
Envoyé : vendredi 30 janvier 2026 23:47
À : Selenium Users <seleniu...@googlegroups.com>
Objet : Re: [selenium-users] Re: c# - sendKeys : decimal number

Reply all
Reply to author
Forward
0 new messages