赛普拉斯5.0全屏截图自动模式

时间:2020-09-13 08:18:56

标签: cypress

我正在使用Cypress5.0。我已经在cypress.json中配置了screenshots文件夹。 而且我正在以编程方式使用赛普拉斯赛跑者API进行测试。

我将视口值用作: config.viewportWidth = 1080; config.viewportHeight = 1024;

屏幕快照即将到来,但它不在整个页面上。我的网页正在滚动,屏幕截图仅占据可见区域。

请指导如何全屏显示屏幕。

我的Cypress.json

{
    "projectId": "yvs41u",
    "video": false,
    "integrationFolder": "integration-tests/experiences",
    "testFiles": "**/*.js",
    "fixturesFolder": false,
    "pluginsFile": "plugins/index.js",
    "supportFile": "support/index.js",
    "screenshotsFolder": "build/reports",
    "videosFolder": "build/reports",
    "videoUploadOnPasses": false,
    "trashAssetsBeforeRuns": false,
    "reporter": "mochawesome",
    "chromeWebSecurity": false,
    "reporterOptions": {
        "charts": true,
        "html": false,
        "json": true,
        "reportDir": "cypress/reports/mochawesome",
        "reportTitle": "Archie Integration Testing Suite",
        "reportFilename": "report",
        "overwrite": false,
        "inline": true,
        "inlineAssets": true,
        "timestamp": "dd-mmm-yyyy-HH-MM-ss"
    }
}

1 个答案:

答案 0 :(得分:1)

默认情况下,Cypress仅捕获视口。为了对整个页面进行屏幕截图,您需要先配置屏幕截图:

Cypress.Screenshot.defaults({ capture: 'fullPage' });
cy.screenshot();

结果将捕获整个页面。

进一步阅读:https://docs.cypress.io/api/cypress-api/screenshot-api.html