2

I'm using Spectron to test an Electron app that is based on React. I'd like to select a React component and I'm trying to access WebDriverIO's browser for that and call react$, however the function cannot be found - 'app.client.react$ is not a function'.

This is my code (with AVA):

test.serial('First Test', async t => {
  const app = t.context.app;

  await app.client.waitUntilWindowLoaded();
  const win = app.browserWindow;
  t.is(await app.client.getWindowCount(), 1);
  t.false(await win.isMinimized());
  t.false(await win.isDevToolsOpened());
  t.true(await win.isVisible());
  t.true(await win.isFocused());
  console.log(await app.client.react$('MyCoponent'));
});

And this is the error:

 TypeError {
    message: 'app.client.react$ is not a function',
  }

Any ideas?

Rani
  • 4,269
  • 1
  • 18
  • 26

1 Answers1

1

Spectron was built on version 4 of WebdriverIO and has not yet been updated to support version 5 (although there is a GitHub issue to do that). React selectors were added to version 5.8.0 of WebdriverIO. When Spectron is updated to support WebdriverIO version 5, then your code should work.

jpolley
  • 124
  • 11