spectron icon indicating copy to clipboard operation
spectron copied to clipboard

keys() returns null

Open andresruizdc opened this issue 3 years ago • 5 comments

Hi, there. I'm testing an Electron app and trying to test whether or not another window is open after a keyboard shortcut. My code is:

  it('Should open the Group Window with Ctrl+G', async () => {
    const test = await app.client.keys(['Control', 'g'])
    const winCount = await app.client.getWindowCount()
    return assert.equal(winCount, 2)
  })

The 'test' variable is null, so I'm guessing that it's not pressing those keys. And yes, the test hasn't passed. Any ideas how to make this work?.

andresruizdc avatar Oct 03 '20 22:10 andresruizdc

I tested this WebDriverIO function with Spectron 10.0.1. In my case the 'test' variable is undefined but the test works and passes because the application performs the expected action. Maybe your problem is another one related to application behavior or getWindowCount() function.

You check this shortcut manually and if it works correctly, then the problem is the keys() function.

jesusiglesias avatar Oct 19 '20 08:10 jesusiglesias

Yes, manually the shortcut its working correctly.

andresruizdc avatar Oct 19 '20 17:10 andresruizdc

Yes, manually the shortcut its working correctly.

Which version are you using?

jesusiglesias avatar Nov 03 '20 08:11 jesusiglesias

I have a similar issue using spectron 13.0.0 and electron 11.1.1 I'm not able to test a shortcut using app.client.keys()

JulienBier avatar Jan 06 '21 01:01 JulienBier

I also have this issue using Spectron 14/Electron 12. Has anyone figured this out?

jeffcrouse avatar May 27 '21 16:05 jeffcrouse