Gemini工作计划AI 评分 · 待评分AI 辅助编辑·未发现明显提示词注入风险n8n.io

用 n8n + Apify + Gemini 实现网站视觉回归自动检测

读取网页 URL → Apify 截图 → Gemini 视觉对比 → Linear 报告;先手动生成基线,再定时巡检

经验丰富步骤流程提示词
给谁
有 n8n 使用经验、需要自动化视觉回归检测的 QA 或前端团队
你会得到
按周自动对比网页截图与基线,发现差异后自动创建 Linear issue
你需要
n8n · apify · google-drive · google-sheets · linear

硬约束

前置条件:n8n 实例;Apify、Google(Drive/Sheets/Gemini)、Linear 的 API 凭证。费用:Apify screenshot actor 按执行次数计费,Gemini API 按调用量计费。输入为 Google Sheets 中的 URL 列表与基线 Drive file ID;输出为 Linear issue 中的回归报告。必须先手动运行 Part A 生成全部基线,再启用 Schedule Trigger。

他们做了什么

作者 redowanfarhan 在 n8n 模板平台发布了一个 29 节点的 workflow,分为两部分:Part A 手动生成基线截图(Apify 截图 → Drive 存储 → Sheets 记录 file ID),Part B 定时巡检(Schedule Trigger 每周一 06:00 启动 → 逐页下载基线与重新截图 → Gemini 1.5 Pro 视觉对比 → Structured Output Parser 强制输出结构化回归列表 → 聚合后创建 Linear issue)。workflow.json 中完整保留了节点参数、连线关系及 sticky note 说明。

效果如何

来源报告该模板适用于 QA 与前端团队进行无需编写断言代码的像素级视觉回归检查(author_report)。模板已被 n8n.io 审核发布(status: published),但本站未执行导入或运行验证。

值得知道

1. 必须先手动运行 Part A 生成全部基线,再启用 Schedule Trigger,否则对比会失败。2. Apify screenshot actor 按次计费,需注意用量与成本。3. workflow.json 中 Drive folderId 与 Sheets documentId 为作者示例值,实际使用时必须替换为自己的资源 ID。4. Gemini 提示词明确忽略 text styling or casing changes,若业务需检测字体变更需自行修改 system message。5. Wait1 仅 1 秒,若 Gemini API 速率限制更严格,可能需要调大。6. 本站未实测,reproduction=not_tested;节点参数以 workflow.json 为准,搭建后请用单条数据测试再批量启用。

n8n 工作流模板

结构已检查 · 未实际运行

下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。

配置与测试清单

需要绑定的凭证

  • 导入后按各需鉴权节点绑定你自己的凭证;本附件不含原作者密钥。

需要替换的配置

  • 源模板来自 n8n 公开库 #16632(约 29 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
  • Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。

测试输入与预期结果

  • 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
  • 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。

模板处理说明

  • 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
  • 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。

模板获取日期: 2026-10-24

步骤

  1. 生成基线截图(手动运行)

    在 n8n 中点击「Test workflow」手动触发。工作流读取 Google Sheets 中缺少基线图片的行(Get URLs with Missing Base Images),对每行 URL 循环执行:调用 Apify screenshot actor 截图 → 等待运行完成 → 下载截图文件 → 上传至 Google Drive → 将 Drive file ID 写回 Sheets 对应行的 base 列。全部 URL 完成基线后,方可进入定时巡检。

    搭建指导 · 来源原文。「Main Overview」粘性说明节点的 content 字段(总览,逐字保留)

    ## 🔍 Visual Regression Testing with Apify & AI Vision
    
    Captures fresh screenshots of your web pages with Apify, compares them against stored baseline images using a Gemini vision model, and files a Linear issue whenever a visual regression is detected.
    
    **Perfect for:** QA engineers and front-end teams who want automated, pixel-aware visual regression checks without writing assertion code.
    
    ---
    
    ## How it works
    
    **Part A — Generate base images (run manually first)**
    
    1. **When clicking 'Test workflow'** — Manually starts the baseline-generation run.
    2. **Get URLs with Missing Base Images** — Reads the Google Sheet for any rows that have a URL but no stored base screenshot.
    3. **Loop Over Items** — Iterates through each URL that needs a baseline.
    4. **Run Webpage Screenshot** — Calls the Apify screenshot actor to capture the page.
    5. **Wait** — Pauses for the Apify run to finish before looping again.
    6. **Merge** — Recombines the loop output with the screenshot result.
    7. **Download Screenshot** — Fetches the rendered screenshot file from the Apify URL.
    8. **Upload to Drive** — Saves the baseline image to Google Drive.
    9. **Update Base Image** — Writes the new Drive file ID back into the Google Sheet.
    
    **Part B — Run the regression test (scheduled)**
    
    10. **Schedule Trigger** — Fires the regression run on a recurring schedule.
    11. **Get Webpages List** — Reads every page to test from the Google Sheet.
    12. **For Each Webpage...** — Loops through each page one at a time.
    13. **Base Image** — Downloads the stored baseline screenshot from Google Drive.
    14. **Run Webpage Screenshot1** — Calls the Apify actor to capture a fresh screenshot.
    15. **Download New Screenshot** — Fetches that fresh screenshot file from Apify.
    16. **Combine Screenshots** — Merges the baseline and the new image into one item.
    17. **Visual Regression Agent** — Sends both images to the AI model to detect differences.
    18. **Google Gemini Chat Model** — The Gemini vision model that performs the comparison.
    19. **Structured Output Parser** — Forces the AI to return a typed list of regressions.
    20. **Wait1** — Throttles between AI calls to respect rate limits.
    21. **Combine Row and Result** — Joins the sheet row with the AI's regression findings.
    22. **Has Changes** — Filters out pages where no regression was found.
    23. **Aggregate** — Collects all flagged pages into a single dataset.
    24. **Create Report** — Files a Linear issue summarising the detected regressions.
    
    ---
    
    ## Setup (~15 minutes)
    
    1. **Apify** — Add your Apify token (Query Auth) in the *Run Webpage Screenshot* and *Run Webpage Screenshot1* nodes.
    2. **Google Sheets** — Connect your account in *Get URLs with Missing Base Images*, *Update Base Image*, and *Get Webpages List*; the sheet needs a URL column and a base-image column.
    3. **Google Drive** — Connect your account in *Base Image* and *Upload to Drive* for baseline storage.
    4. **Google Gemini (PaLM) API** — Add your key in the *Google Gemini Chat Model* node.
    5. **Linear** — Connect your Linear API credential in the *Create Report* node and pick the target team.
    > Run Part A manually first to seed every page's baseline before enabling the Schedule Trigger. Apify screenshot runs are billed per execution, so watch your actor usage.
  2. 定时捕获新截图(Schedule Trigger)

    启用 Schedule Trigger(默认每周一 06:00 执行)。工作流读取 Sheets 中全部待测网页(Get Webpages List),逐页循环:从 Drive 下载该页基线截图 → 调用 Apify 重新截图 → 下载新截图 → 将基线与最新截图合并为单一数据项,供下游 AI 节点处理。

  3. Gemini 视觉回归对比

    Visual Regression Agent 节点将两张截图发送至 Google Gemini Chat Model(gemini-1.5-pro-latest)。节点内定义 system 提示词要求模型识别文本、图片、颜色、位置与布局变化,忽略字体样式或大小写变更;两张图分别以 binary image data_1(基线)和 data_2(新图)传入。Structured Output Parser 强制模型返回固定 JSON Schema 的数组,每项包含 type、description、previous_state、current_state。Wait1 节点在每次 AI 调用后等待 1 秒以控制速率。

    运行提示词 · 来源原文。Visual Regression Agent 节点的 text 字段(chainLlm 主指令)

    Identify changes between the base image and test image.

    运行提示词 · 来源原文。Visual Regression Agent 节点的 messages.messageValues[0].message(system prompt)

    =You help with visual regression testing for websites. Identify changes to text content, images, colors, position and layouts of the elements in the screenshots. Ignore text styling or casing changes.
    The first image will be the base image and the second image will be the test. Note all changes to the test image which differ from the base. If there are no changes, it is okay to return an empty array.

    运行提示词 · 来源原文。Structured Output Parser 节点的 inputSchema 字段

    {
     "type": "array",
     "items": {
     "type": "object",
    	"properties": {
    		"type": {
     		"type": "string",
     "description": "type of regression. One of text, number, image, color or position."
     		},
    		"description": { "type": "string" },
     "previous_state": { "type": "string" },
     "current_state": { "type": "string" }
    	}
     }
    }
  4. 汇总并创建 Linear 报告

    Combine Row and Result 将 Sheets 行数据与 AI 输出合并;Has Changes 过滤掉 output 为空数组的页面;Aggregate 将所有有变更的页面聚合为单一数据集;Create Report 在 Linear 创建 issue,标题含日期,正文列出每页 URL 及其具体回归项(description、previous_state、current_state)。

    运行提示词 · 来源原文。Create Report 节点的 title 字段

    =Visual Regression Report {{ $now.format('yyyy-MM-dd') }}

    运行提示词 · 来源原文。Create Report 节点的 additionalFields.description 字段

    =Visual Regression Workflow picked up the following changes:
    
    {{
    $json.data.map(row =>
    `### ${row.url}
    ${row.output.map(issue =>
    `* **${issue.description}** - expected "${issue.previous_state}" but got "${issue.current_state}"`
    ).join('\n')}`
    ).join('\n');
    }}
  5. 配置凭证与权限

    按顺序完成以下 5 项凭证配置(预计约 15 分钟):1) Apify:在 Run Webpage Screenshot 与 Run Webpage Screenshot1 节点添加 API token,认证方式选 HTTP Query Auth;2) Google Sheets:在 Get URLs with Missing Base Images、Update Base Image、Get Webpages List 节点连接账号,确认表格包含 url 与 base 两列;3) Google Drive:在 Base Image(下载)与 Upload to Drive(上传)节点连接账号,设定基线图片存放文件夹;4) Google Gemini:在 Google Gemini Chat Model 节点添加 API key;5) Linear:在 Create Report 节点连接 API credential 并选择目标 team ID。

  6. 主搭建提示词(可选)

    如需在 AI 助手协助下复现或排查,可使用以下启动词说明目标与输入变量。

    搭建指导 · 本站建议版本。交给搭建助手,先确认输入表格结构与权限

    You are a setup assistant for an n8n visual-regression workflow. The workflow uses Apify to capture screenshots, Google Drive/Sheets for baseline storage, Google Gemini (gemini-1.5-pro-latest) for vision comparison, and Linear for issue tracking. Inputs: a Google Sheet with columns 'url' and 'base' (Drive file ID). Before enabling the Schedule Trigger, run the manual baseline-generation branch once to populate 'base' for every row. Apify screenshot actor is billed per execution; monitor usage. Confirm credentials are configured for all 5 services before testing.

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入表格结构与权限

这一段是提示词,页面不会在这里插入广告。

You are a setup assistant for an n8n visual-regression workflow. The workflow uses Apify to capture screenshots, Google Drive/Sheets for baseline storage, Google Gemini (gemini-1.5-pro-latest) for vision comparison, and Linear for issue tracking. Inputs: a Google Sheet with columns 'url' and 'base' (Drive file ID). Before enabling the Schedule Trigger, run the manual baseline-generation branch once to populate 'base' for every row. Apify screenshot actor is billed per execution; monitor usage. Confirm credentials are configured for all 5 services before testing.

搭建前请确认 Google Sheets 已包含 url 与 base 列,且已手动跑通基线分支。

来源

Detect visual regressions with Apify, Google Gemini, Sheets and Linear · redowanfarhan · n8n.io · 2026-06-25

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例