TestCafe with Electron: Determine if app is visible on Windows desktop

馋奶兔 提交于 2019-12-05 19:01:24

It can be done using Electron's API. Please refer to the following article to get details: https://electronjs.org/docs/api/browser-window#winisvisible

And here is the test code:

import { ClientFunction } from 'testcafe';

fixture `Electron page`
    .page ``;

const isDocumentHidden = ClientFunction(() => {
    const remote = require('electron').remote;
    const win = remote.getCurrentWindow();

    return !win.isVisible();
});

test('is hidden', async t => {
    console.log(await isDocumentHidden());
});

I checked the code on your project and it works as expected.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!