testing - 带有 Electron 的 TestCafe : Determine if app is visible on Windows desktop

标签 testing automation electron e2e-testing testcafe

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

如果我尝试通过 methods such as this 获取可见性信息或 described here ,检查“可见”属性总是返回 true

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

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

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

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

谢谢 米

最佳答案

可以使用 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());
});

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

关于testing - 带有 Electron 的 TestCafe : Determine if app is visible on Windows desktop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58369151/

相关文章:

java - 在方法中设置私有(private)变量和读取值

javascript - Protractor - 打开弹出窗口时,它不会等待此窗口内的所有元素

pdf - 使用 Applescript 进行 Photoshop 脚本编写 - 在没有提示的情况下不会打开图像

azure - 检查 Azure 自动化 Runbook (PowerShell) 运行位置的方法是什么?

node.js - 如何在 Electron 应用程序中路径到图像文件?

angular - Electron 找不到资源

javascript - 使用 Electron 将 Angular 项目(进行 REST API 调用)转换为桌面应用程序

ruby-on-rails - 任何人都知道全套的 Devise Rspec/Capybara 测试

angular - 类型错误 : Cannot read property 'prod_id' of undefined

javascript - javascript测试中的异步断言