如何在Testcafe中将``resizeWindow''与docker和electronic一起使用? [英] How to use 'resizeWindow' with docker and electron in Testcafe?

查看:105
本文介绍了如何在Testcafe中将``resizeWindow''与docker和electronic一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Testcafe <中使用 resizeWindow 有问题/ a>在docker容器中,同时使用gitlab测试电子应用。

I have an issue using resizeWindow from Testcafe inside a docker container while testing an electron app with gitlab.

注意:在本地设置(linux)上,所有测试均按预期进行,但在docker容器 resizeWindow 似乎不起作用。

Note: On local setup (linux) all tests work as expected, but inside the docker container resizeWindow does not seem to work. Other tests inside the container work as well.

也许我缺少 xvfb 的任何配置,或者我应该使用 fluxbox

Maybe i'm missing any configuration for xvfb or should i use fluxbox?

任何建议如何解决这个问题?

Any suggestion how to solve this?

$ yarn test-e2e-ci
yarn run v1.22.4
$ node -r @babel/register ./internals/scripts/CheckBuildsExist.js && cross-env NODE_ENV=test testcafe electron:./ci ./test/e2e/DockerTest.e2e.ts --screenshots takeOnFails=true
 Running tests in:
 - Electron 9.0.4 / Linux 0.0
 Docker execution
 ✖ `ResizeWindow` works as expected 
   1) AssertionError: expected 1024 to deeply equal 100
      Browser: Electron 9.0.4 / Linux 0.0
          8 |
          9 |test('`ResizeWindow` works as expected ', async t => {
         10 |  await t.resizeWindow(100, 100);
         11 |  const innerWidth = await t.eval(() => window.innerWidth);
         12 |  const innerHeight = await t.eval(() => window.innerHeight);
       > 13 |  await t.expect(innerWidth).eql(100);
         14 |  await t.expect(innerHeight).eql(100);
         15 |});
         16 |
         at <anonymous>
      (/builds/myFancyProject/test/e2e/DockerTest.e2e.ts:13:30)
         at fulfilled
      (/builds/myFancyProject/test/e2e/DockerTest.e2e.ts:5:58)
 1/1 failed (8s)




警告:


 Warnings (3):
 --
  Was unable to resize the window due to an error.
  The
  /builds/myFancyProject/node_modules/testcafe-browser-tools/bin/linux/glibc-64/resize
  process failed with the null exit code.
 --




使用的测试设置:


ResizeWindow Testcafe测试


test('`ResizeWindow` works as expected ', async t => {
  await t.resizeWindow(100, 100);
  const innerWidth = await t.eval(() => window.innerWidth);
  const innerHeight = await t.eval(() => window.innerHeight);
  await t.expect(innerWidth).eql(100);
  await t.expect(innerHeight).eql(100);
});


在gitlab yml中启动


-xvfb-运行--server-num = 99 --server-args ='-ac -screen 0 1024x768x16'yarn test-e2e-ci

test-e2e-ci: node -r @ babel / register ./internals/scripts/CheckBuildsExist.js&& cross-env NODE_ENV = test testcafe electronic:./ ci ./test/e2e/ --screenshots takeOnFails = true,

{
  "mainWindowUrl": "../app/app.html",
  "appPath": "../app",
  "appArgs": "--no-sandbox"
}


已测试的docker镜像:


circleci / node:最新浏览器

FROM node:lts-stretch

RUN apt-get update \
    && apt-get install -y xvfb \
    libnotify4 \
    libgconf2-4 \
    libnss3 \
    libxtst-dev \
    libc6 \
    libstdc++6 \
    libgcc1 \
    libgtk-3-0 \
    libasound2 \
    libxrender1 \
    libxss1


推荐答案

您需要正确安装和设置 fluxbox 工具。
请参阅TestCafe docker相关文件中的示例:

You need to correctly install and setup the fluxbox tool. See an example in TestCafe docker related files:

  • https://github.com/DevExpress/testcafe/blob/master/docker/Dockerfile
  • https://github.com/DevExpress/testcafe/blob/master/docker/testcafe-docker.sh

这篇关于如何在Testcafe中将``resizeWindow''与docker和electronic一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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