microsoft / WinAppDriver

Windows Application Driver
MIT License
3.68k stars 1.4k forks source link

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

Open mcsia opened 2 years ago

mcsia commented 2 years ago

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");)
Shakevg commented 2 years ago

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

mcsia commented 2 years ago

@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

anunay1 commented 2 years ago

@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");)