【问题标题】:TestCafe with Electron: Determine if app is visible on Windows desktopTestCafe with Electron:确定应用程序是否在 Windows 桌面上可见
【发布时间】:2019-10-14 01:42:41
【问题描述】:

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

如果我尝试通过methods such as thisdescribed here 获取可见性信息,检查'visible' 属性总是返回true

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

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

作为一个万岁,我还尝试检查“focused”属性,但无论应用程序在桌面上的可见性如何,它也总是返回 true(至少在“body”上) .

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

谢谢 米

【问题讨论】:

    标签: testing automation electron e2e-testing testcafe


    【解决方案1】:

    可以使用 Electron 的 API 来完成。详情请参考以下文章: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());
    });
    

    我检查了您项目上的代码,它按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      • 2010-09-14
      • 1970-01-01
      • 2016-03-05
      • 2018-02-05
      • 1970-01-01
      相关资源
      最近更新 更多