带有Electron的TestCafe:确定应用程序是否在Windows桌面上可见 [英] TestCafe with Electron: Determine if app is visible on Windows desktop

查看:371
本文介绍了带有Electron的TestCafe:确定应用程序是否在Windows桌面上可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的Electron应用程序开始最小化到Windows托盘通知区域,即在桌面上不可见.

Our Electron application starts minimized to the Windows tray notification area i.e. not visible on the desktop.

如果我尝试通过这样的方法 true .

If I attempt to get visibility information through methods such as this or as described here, checking the 'visible' property always returns true.

例如,无论应用程序最小化到通知区域还是在桌面上可见,以下内容始终返回 true :

For example, the below always returns true whether the app is minimized to the notification area or visible on the desktop:

if(await Selector('button', { visibilityCheck: true }).visible)
    console.log("VISIBLE");
  else
    console.log("NOT VISIBLE");

作为一个冰雹玛丽,我还尝试检查"focused"属性,但是无论应用程序在桌面上的可见性如何,该属性始终总是返回 true (至少在"body"上)

As a hail-mary, I have also attempted to check the 'focused' property but that also always returns true (at least on the 'body') regardless of the application's visibility on the desktop.

有人知道通过TestCafe确定该应用程序在Windows桌面上是否可见的可靠方法吗?

Does anyone know of a reliable method through TestCafe to determine if the application is visible on the Windows desktop?

谢谢 m

推荐答案

可以使用Electron的API来完成.请参阅以下文章以获取详细信息: https://electronjs.org/docs/api/browser-window#winisvisible

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

这是测试代码:

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.

这篇关于带有Electron的TestCafe:确定应用程序是否在Windows桌面上可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆