WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Unable to pass values using SendKeys() while automating desktop application using WinAppDriver

Open mcsia opened this issue 3 years ago • 3 comments

I am unable to send values to input field of desktop application. Say for example, in Notepad, on Ctrl+F, 'Find Next' pop up appears. I couldn't send values to the Find Next: input field using sendKeys method. I am able to send values to the text editor of notepad though. I am trying to find a solution using SendKeys method.

Below is the code----

(capabilities.setCapability("app", "C:\\Windows\\System32\\notepad.exe");
 capabilities.setCapability("platformName","Windows");
 capabilities.setCapability("deviceName", "WindowsPC");
 notepadSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
notepadSession.findElement(By.name("Text Editor")).sendKeys("Hi there!");
Robot r= new Robot();
r.keyPress(KeyEvent.VK_CONTROL);
r.keyPress(KeyEvent.VK_F);
r.keyRelease(KeyEvent.VK_CONTROL);
r.keyRelease(KeyEvent.VK_F);
Thread.sleep(2000);
notepadSession.findElement(By.name("Find")).findElement("Find what:")).sendKeys("Hi");)

mcsia avatar Feb 10 '22 14:02 mcsia

@mcsia Could you please post the WinAppDriver log and error from your test

Shakevg avatar Feb 10 '22 19:02 Shakevg

@Shakevg This line passed without any error. I tried even next step to click on Find Next button. It tried to find the default text 'path' in the text editor. So basically it did not send values to the input field but the line runs without failure Attaching the WinAppDriver log WinApplog.txt

mcsia avatar Feb 10 '22 20:02 mcsia

@mcsia I don't know whether you are still facing the problem can you try this:

notepadSession.findElement(By.name("Find")).findElements("Find what:"))[1].sendKeys("Hi");)

anunay1 avatar Mar 03 '22 15:03 anunay1