lundi 1 juillet 2019

How to select a React component with Spectron?

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?

Aucun commentaire:

Enregistrer un commentaire