1

I use Selenium with the latest Chromedriver, the Script opens a Windows Window to Select a Picture to Upload.

It's working, but the typing is so slow, like slow-motion 10 Letters > 3-5 Sec....

I use this Command:

SendKeys.SendWait(...);

On the other Side, in the Chrome Window, the SendKeys is so fast, you can't see that is typing, the text is instant here, but not in the Windows Window for Uploading a Pic...

 driver.FindElement(By.XPath("...")).SendKeys("...");

Anyone have an Idea why that happens and how I can solve this?

stersym
  • 308
  • 1
  • 6
  • 15
Shanapoia
  • 23
  • 4
  • Ever since Windows Vista it’s advised not to rely on send keys working. Consider using _Microsoft UI Automation_ instead. It uses a different approach for app automation –  Jan 21 '22 at 03:40

1 Answers1

0

Maybe this will help you How to handle windows file upload using Selenium WebDriver?

I think

SendKeys.SendWait(...);

is working this way - add a list with letters, then type first, waits when completed and only then adding next one. That why adding more letters will take longer to complete it.

There is Remark from - https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.sendwait?view=windowsdesktop-6.0

Use SendWait to send keystrokes or combinations of keystrokes to the active application and wait for the keystroke messages to be processed. You can use this method to send keystrokes to an application and wait for any processes that are started by the keystrokes to be completed. This can be important if the other application must finish before your application can continue.

Your Selenium code:

driver.FindElement(By.XPath("...")).SendKeys("...");

Is adding your full string of text from your "..." to web element.. that why your full text is already in your element. Same as copy and paste.

Multispeed
  • 97
  • 1
  • 7
  • Hmmm... Is there then too a Option to Copy/Paste with SendKeys.SendWait(...); like my Selenium Code? or another way to copy/paste into the windows window? – Shanapoia Jan 21 '22 at 23:59
  • 1
    you can try add your text to clipboard with code : `Clipboard.SetText("......");` and then use `SendKeys.Send("^v");` or `SendKeys.SendWait("^v");` – Multispeed Jan 22 '22 at 07:52
  • 1
    Yea, i got the same thing with Clipboard and Paste it in :) Thanks – Shanapoia Jan 23 '22 at 21:28