首页 > 解决方案 > 无法调整在 Chrome 无头上运行 TestCafe 的窗口大小

问题描述

尝试在测试中使用 .resizeWindow 时出现错误,但仅当我针对无头模式运行测试时它才会失败。声明为警告的错误如下:

    Warnings (1):
 --
  Was unable to resize the window due to an error.

  Cannot read property 'Emulation' of undefined

我正在运行我的测试:

 - HeadlessChrome 70.0.3538 / Mac OS X 10.13.6
 Testcafe version 0.20.4

resizeWindow 指令在我的 beforeEach 中设置如下:

 .beforeEach(async t => {
      await t.navigateTo(`${testDomain}${Var.url_listing_general}`)
        .resizeWindow(1420, 750);
    }
  });

标签: google-chrometestingautomated-teststestcafegoogle-chrome-headless

解决方案


您是否尝试过不beforeEach部分调整大小,而是在第一行进行测试?

另外,也许这很愚蠢而且不重要,但是在您的代码示例中,您}在末尾beforeEach部分有额外的内容,这会导致问题吗?


推荐阅读