-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Expand file tree
/
Copy pathVisual Regression Testing with Apify and AI Vision Model.json
More file actions
1001 lines (1001 loc) · 22.9 KB
/
Visual Regression Testing with Apify and AI Vision Model.json
File metadata and controls
1001 lines (1001 loc) · 22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"meta": {
"instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9"
},
"nodes": [
{
"id": "cb62c9a5-2f43-4328-af94-84c2cb731d9c",
"name": "Base Image",
"type": "n8n-nodes-base.googleDrive",
"position": [
260,
660
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.base }}"
},
"options": {
"binaryPropertyName": "data_1"
},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "yOwz41gMQclOadgu",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "b1c304cc-9949-441a-ac2a-275c8d4c51fc",
"name": "Google Gemini Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
1120,
900
],
"parameters": {
"options": {},
"modelName": "models/gemini-1.5-pro-latest"
},
"credentials": {
"googlePalmApi": {
"id": "dSxo6ns5wn658r8N",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "964d94bf-be2a-424e-ab0e-c1c1fe260ebd",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1320,
900
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n\t\"properties\": {\n\t\t\"type\": {\n \t\t\"type\": \"string\",\n \"description\": \"type of regression. One of text, number, image, color or position.\"\n \t\t},\n\t\t\"description\": { \"type\": \"string\" },\n \"previous_state\": { \"type\": \"string\" },\n \"current_state\": { \"type\": \"string\" }\n\t}\n }\n}"
},
"typeVersion": 1.2
},
{
"id": "67195eb2-1729-42b0-8275-bdd6128b81aa",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2340,
20
],
"parameters": {
"color": 4,
"width": 405.95003875719203,
"height": 180.74812634463558,
"content": "### Part A. Generate Base Images\nBefore we can run our visual regression tests, we must generate a series of base screenshots to compare against. This part of the workflow uses an external website screenshotting service, [Apify.com](https://www.apify.com?fpr=414q6), to achieve this. This part of the workflow should only be run when we want to update our base screenshots."
},
"typeVersion": 1
},
{
"id": "85f9b371-1710-4c9c-a0ed-210d9c0e5d64",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
162.7495769165307,
500
],
"parameters": {
"color": 7,
"width": 702.1744987652204,
"height": 548.4621171664835,
"content": "## 5. Download Base and Generate new Webpage Screenshot\n[Learn more about Apify.com](https://www.apify.com?fpr=414q6)\n\nLooping for each webpage, we'll do 2 tasks (1) download the base screenshot for the url and (2) and use our [Apify.com](https://www.apify.com?fpr=414q6) webpage screenshot actor again to generate a fresh screenshot."
},
"typeVersion": 1
},
{
"id": "8bff4efc-d9f9-485c-b51d-a8edc29d1105",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
900,
500
],
"parameters": {
"color": 7,
"width": 759.5372282495247,
"height": 548.702446115556,
"content": "## 6. Compare Screenshots using Vision Model\n[Read more about the basic LLM chain](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm/)\n\nTo carry out our visual regression test, we need to send both screenshots simultaneously to our Vision model. This is easily achieved using n8n's built-in basic LLM chain where we can define two user messages of the binary type. For our vision model, we'll use Google's Gemini but any capable vision model will also do the job. A Structured Output Parser is used here to return the AI's response in JSON format, this is for easier formatting purposes which we'll get to in the next step."
},
"typeVersion": 1
},
{
"id": "a92d11e5-0985-4a8f-bc43-8bc0ca48e744",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
397.518987341772,
93.8157360237642
],
"parameters": {
"color": 7,
"width": 885.2402868841493,
"height": 388.92815062755926,
"content": "## 7. Create Report In Linear\n[Learn more about integrating with Linear.app](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.linear)\n\nFor the final step, we'll generate a simple report which will capture any changes detected in our webpages list. Let's do this by first combining our webpages with their test results and filter out any in the page where no changes were detected. Next, we'll aggregate all changes into the Linear.app node which will be formatted into a markdown snippet and used to create a new issue in Linear. If you don't use Linear, feel free to swap this out for JIRA or even Slack."
},
"typeVersion": 1
},
{
"id": "3f52c006-6c0a-456d-ab3c-ee5a16726299",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-1680,
580
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "478ee25d-3f0f-4f6c-bf34-add1dc14c3cb",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
-1240,
820
],
"webhookId": "f06eab66-30a7-48ad-90ee-cb3394eb2edb",
"parameters": {
"amount": 2
},
"typeVersion": 1.1
},
{
"id": "64b5f755-a85e-4ae5-ad81-113c1ef9b64c",
"name": "Download Screenshot",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1260,
360
],
"parameters": {
"url": "={{ $json.screenshotUrl }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "8f99ef1f-1cdc-4d80-b858-e9960a805dd4",
"name": "Upload to Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
-1080,
360
],
"parameters": {
"name": "={{ $('Merge').item.json.url.urlEncode() }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {
"simplifyOutput": true
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1lAFxJPWcA_sOcjr3UUKKfFfoTwd4Stkh",
"cachedResultUrl": "https://drive.google.com/drive/folders/1lAFxJPWcA_sOcjr3UUKKfFfoTwd4Stkh",
"cachedResultName": "base_images"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "yOwz41gMQclOadgu",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "5e253123-89ba-42d5-b743-60bfd1ebae5b",
"name": "Update Base Image",
"type": "n8n-nodes-base.googleSheets",
"position": [
-900,
360
],
"parameters": {
"columns": {
"value": {
"url": "={{ $('Merge').item.json.url }}",
"base": "={{ $json.id }}"
},
"schema": [
{
"id": "service",
"type": "string",
"display": true,
"required": false,
"displayName": "service",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "base",
"type": "string",
"display": true,
"required": false,
"displayName": "base",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"url"
]
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84/edit?usp=drivesdk",
"cachedResultName": "Visual Regression List"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "XHvC7jIRR8A2TlUl",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "fa7339b7-b7dd-4ecd-8dc2-f42f6549adb6",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"position": [
-1440,
360
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3
},
{
"id": "47845df9-a50e-429e-b81e-5eefd996d5c7",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-560,
380
],
"parameters": {
"rule": {
"interval": [
{
"field": "weeks",
"triggerAtDay": [
1
],
"triggerAtHour": 6
}
]
}
},
"typeVersion": 1.2
},
{
"id": "63492aa4-3535-4832-a9d0-0a949e46ec81",
"name": "Get URLs with Missing Base Images",
"type": "n8n-nodes-base.googleSheets",
"position": [
-1980,
480
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84/edit?usp=drivesdk",
"cachedResultName": "Visual Regression List"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "XHvC7jIRR8A2TlUl",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "8907f3b9-0613-4057-8adb-fd5c4e25cf72",
"name": "Run Webpage Screenshot",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1420,
820
],
"parameters": {
"url": "https://api.apify.com/v2/acts/apify~screenshot-url/run-sync-get-dataset-items",
"method": "POST",
"options": {},
"jsonBody": "={{\n{\n \"delay\": 0,\n \"format\": \"png\",\n \"proxy\": {\n \"useApifyProxy\": true\n },\n \"scrollToBottom\": false,\n \"urls\": [\n {\n \"url\": $json.url\n }\n ],\n \"viewportWidth\": 1280,\n \"waitUntil\": \"domcontentloaded\",\n \"waitUntilNetworkIdleAfterScroll\": false\n}\n}}",
"sendBody": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpQueryAuth"
},
"credentials": {
"httpQueryAuth": {
"id": "cO2w8RDNOZg8DRa8",
"name": "Apify API"
}
},
"typeVersion": 4.2
},
{
"id": "3dc45b2d-4c4a-44d5-9b45-3e2144479603",
"name": "Run Webpage Screenshot1",
"type": "n8n-nodes-base.httpRequest",
"position": [
273,
833
],
"parameters": {
"url": "https://api.apify.com/v2/acts/apify~screenshot-url/run-sync-get-dataset-items",
"method": "POST",
"options": {},
"jsonBody": "={{\n{\n \"delay\": 0,\n \"format\": \"png\",\n \"proxy\": {\n \"useApifyProxy\": true\n },\n \"scrollToBottom\": false,\n \"urls\": [\n {\n \"url\": $json.url\n }\n ],\n \"viewportWidth\": 1280,\n \"waitUntil\": \"domcontentloaded\",\n \"waitUntilNetworkIdleAfterScroll\": false\n}\n}}",
"sendBody": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpQueryAuth"
},
"credentials": {
"httpQueryAuth": {
"id": "cO2w8RDNOZg8DRa8",
"name": "Apify API"
}
},
"typeVersion": 4.2
},
{
"id": "672d64fb-7782-427e-8779-953e51118fbc",
"name": "Has Changes",
"type": "n8n-nodes-base.filter",
"position": [
680,
300
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "20b18a7e-bf98-4f39-baa9-4d965097526a",
"operator": {
"type": "array",
"operation": "lengthGt",
"rightType": "number"
},
"leftValue": "={{ $json.output }}",
"rightValue": 0
}
]
}
},
"typeVersion": 2.2
},
{
"id": "efa168ec-ff05-471b-869f-cee5a222594a",
"name": "Combine Row and Result",
"type": "n8n-nodes-base.set",
"position": [
500,
300
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={{\n{\n ...$('Get Webpages List').item.json,\n output: $json.output\n}\n}}\n"
},
"typeVersion": 3.4
},
{
"id": "1fe901dc-f460-41b8-8042-0fcb0474092f",
"name": "Wait1",
"type": "n8n-nodes-base.wait",
"position": [
1580,
900
],
"webhookId": "6bbf2e65-bed1-4efc-bb31-09d12c644dc5",
"parameters": {
"amount": 1
},
"typeVersion": 1.1
},
{
"id": "7891f052-4073-4746-a04b-27c7c4fa1e63",
"name": "Aggregate",
"type": "n8n-nodes-base.aggregate",
"position": [
860,
300
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "ef2b2ddb-51f9-4576-bd99-9efa39be5163",
"name": "Create Report",
"type": "n8n-nodes-base.linear",
"position": [
1040,
300
],
"parameters": {
"title": "=Visual Regression Report {{ $now.format('yyyy-MM-dd') }}",
"teamId": "1c721608-321d-4132-ac32-6e92d04bb487",
"additionalFields": {
"description": "=Visual Regression Workflow picked up the following changes:\n\n{{\n$json.data.map(row =>\n`### ${row.url}\n${row.output.map(issue =>\n`* **${issue.description}** - expected \"${issue.previous_state}\" but got \"${issue.current_state}\"`\n).join('\\n')}`\n).join('\\n');\n}}"
}
},
"credentials": {
"linearApi": {
"id": "Nn0F7T9FtvRUtEbe",
"name": "Linear account"
}
},
"typeVersion": 1
},
{
"id": "477b89f7-00ca-4001-a246-0887bcb553eb",
"name": "When clicking ‘Test workflow’",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-2180,
480
],
"parameters": {},
"typeVersion": 1
},
{
"id": "eb7f6310-5465-4638-b702-5ecbd98a0199",
"name": "Get Webpages List",
"type": "n8n-nodes-base.googleSheets",
"position": [
-360,
380
],
"parameters": {
"options": {},
"filtersUI": {
"values": [
{
"lookupValue": "2",
"lookupColumn": "=row_number"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RbobwHCJiYKnic6T-VA3kPr-Grd4Y_ZSQXqy2st_T84/edit?usp=drivesdk",
"cachedResultName": "Visual Regression List"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "XHvC7jIRR8A2TlUl",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "6c0f7341-14c9-48c2-9447-edab0ad18df7",
"name": "For Each Webpage...",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-40,
440
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "62e13166-458d-4c63-8911-740f9ceaeb54",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-660,
160
],
"parameters": {
"color": 7,
"width": 561.2038065501644,
"height": 408.0284015307624,
"content": "## 4. Trigger Visual Regression Test Run\n[Read more about the Schedule Trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger/)\n\nOnce we've generated our base images to compare with in Part A, we can now run our Visual Regression Tests. These tests are intended to check for unexpected changes to a webpage by using some form of image detection. To trigger Part B, we'll start with a schedule trigger and pull a list of webpages to test from Google Sheets."
},
"typeVersion": 1
},
{
"id": "8d958f44-fd2c-49b4-adbd-d8a99b2614c8",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2340,
218.0216140230686
],
"parameters": {
"color": 7,
"width": 626.9985071319608,
"height": 487.40071048786325,
"content": "## 1. Get List of Webpages to Generate Base Images\n[Learn more about using Google Sheets](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets/)\n\nThis workflow is split into 2 parts: Part A will generate the \"base\" screenshots to compare new screenshots against. To capture these base screenshots, we'll use Google Sheets to hold our list of webpages and their screenshot references (we'll come on to that later).\n\nExample Sheet: https://docs.google.com/spreadsheets/d/e/2PACX-1vTXRZRi55dUbLAsWZboJqH5U-EK0ZRSse8pkqANAV4Ss70otpQ97zgT8YBd3dL4d2u2UC1TTx_o1o1R/pubhtml"
},
"typeVersion": 1
},
{
"id": "ee776b4d-4532-4c08-ac38-35d40afbd8ad",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1480,
580
],
"parameters": {
"color": 7,
"width": 653.369086691465,
"height": 443.1120543367141,
"content": "## 2. Generate Webpage Screenshot via Apify\n[Learn more about Apify.com](https://www.apify.com?fpr=414q6)\n\nTo generate a screenshot of the webpage, we'll need a third party service since this functionality is outside the scope of n8n. Feel free to pick whichever internal or external service works for you but I've had great experience using [Apify.com](https://www.apify.com?fpr=414q6) - a popular webscraping SaaS who offer a generous free plan and require very little configuration to get started.\n\nThe Apify \"actor\" (ie. a type of scraper) we'll be using is specifically designed to take webpage screenshots."
},
"typeVersion": 1
},
{
"id": "3d90e103-2829-4075-b3d4-5ba848af4843",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1520,
160
],
"parameters": {
"color": 7,
"width": 808.188722669735,
"height": 397.73072497123115,
"content": "## 3. Upload Screenshot to Google Drive\n[Read more about using the Google Drive node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googledrive/)\n\nOnce we have our screenshots, we'll download them from Apify and upload them to our Google Drive for safe keeping. After uploading, we'll capture the new Google Drive IDs for the images into our Google Sheet, this will allow us to reference them again when we perform the visual regression testing."
},
"typeVersion": 1
},
{
"id": "e47d14ec-ad78-42c8-a294-301dcd581a67",
"name": "Download New Screenshot",
"type": "n8n-nodes-base.httpRequest",
"position": [
453,
833
],
"parameters": {
"url": "={{ $json.screenshotUrl }}",
"options": {
"response": {
"response": {
"responseFormat": "file",
"outputPropertyName": "data_2"
}
}
}
},
"typeVersion": 4.2
},
{
"id": "8ca118bc-3d19-48ac-9d9c-0892993da736",
"name": "Combine Screenshots",
"type": "n8n-nodes-base.merge",
"position": [
660,
660
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3
},
{
"id": "03359cbb-d7af-4118-a32a-3fe24062dc9f",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-660,
20
],
"parameters": {
"color": 4,
"width": 394.03359370567625,
"height": 111.52173490405977,
"content": "### Part B. Run Visual Regression Test\nIn this part of the workflow, we'll retrieve our list of webpages to test with our AI vision model. This part can be run as many times as required."
},
"typeVersion": 1
},
{
"id": "a78c0f92-aa61-483b-95bf-dd60958f182d",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2920,
220
],
"parameters": {
"width": 553.2963720930223,
"height": 473.4987906976746,
"content": "## Try It Out!\n\n### This workflow implements an approach to Visual Regression Testing - a means to test websites for defects - using AI Vision Models.\n\nThis workflow uses a Google Sheet to track a list of webpages to test and is split into 2 parts; Part A generates the base screenshots of the list and Part B runs the visual regression testing.\n\nThe example spreadsheet can be found here: https://docs.google.com/spreadsheets/d/e/2PACX-1vTXRZRi55dUbLAsWZboJqH5U-EK0ZRSse8pkqANAV4Ss70otpQ97zgT8YBd3dL4d2u2UC1TTx_o1o1R/pubhtml\n\n**[Apify.com](https://www.apify.com?fpr=414q6)** is the screenshot generator of choice and a free account with $5 in credit is available via this [link](https://www.apify.com?fpr=414q6).\n\n\n### Need Help?\nJoin the [Discord](https://discord.com/invite/XPKeKXeB7d) or ask in the [Forum](https://community.n8n.io/)!"
},
"typeVersion": 1
},
{
"id": "a0b257e5-99f8-409a-bc67-2468db377d6c",
"name": "Visual Regression Agent",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1120,
740
],
"parameters": {
"text": "Identify changes between the base image and test image.",
"messages": {
"messageValues": [
{
"message": "=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.\nThe 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."
},
{
"type": "HumanMessagePromptTemplate",
"messageType": "imageBinary",
"binaryImageDataKey": "data_1"
},
{
"type": "HumanMessagePromptTemplate",
"messageType": "imageBinary",
"binaryImageDataKey": "data_2"
}
]
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.4
}
],
"pinData": {},
"connections": {
"Wait": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Download Screenshot",
"type": "main",
"index": 0
}
]
]
},
"Wait1": {
"main": [
[
{
"node": "For Each Webpage...",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Create Report",
"type": "main",
"index": 0
}
]
]
},
"Base Image": {
"main": [
[
{
"node": "Combine Screenshots",
"type": "main",
"index": 0
}
]
]
},
"Has Changes": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
],
[
{
"node": "Run Webpage Screenshot",
"type": "main",
"index": 0
}
]
]
},
"Upload to Drive": {
"main": [
[
{
"node": "Update Base Image",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get Webpages List",
"type": "main",
"index": 0
}
]
]
},
"Get Webpages List": {
"main": [
[
{
"node": "For Each Webpage...",
"type": "main",
"index": 0
}
]
]
},
"Combine Screenshots": {
"main": [
[
{
"node": "Visual Regression Agent",
"type": "main",
"index": 0
}
]
]
},
"Download Screenshot": {
"main": [
[
{
"node": "Upload to Drive",
"type": "main",
"index": 0
}
]
]
},
"For Each Webpage...": {
"main": [
[
{
"node": "Combine Row and Result",
"type": "main",
"index": 0
}
],
[
{
"node": "Base Image",
"type": "main",
"index": 0
},
{
"node": "Run Webpage Screenshot1",
"type": "main",
"index": 0
}
]
]
},
"Combine Row and Result": {
"main": [
[
{
"node": "Has Changes",
"type": "main",
"index": 0
}
]
]
},
"Run Webpage Screenshot": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Download New Screenshot": {
"main": [
[
{
"node": "Combine Screenshots",
"type": "main",
"index": 1
}
]
]
},
"Run Webpage Screenshot1": {
"main": [
[
{
"node": "Download New Screenshot",
"type": "main",
"index": 0
}
]
]
},
"Visual Regression Agent": {
"main": [
[
{
"node": "Wait1",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Visual Regression Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Visual Regression Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Get URLs with Missing Base Images": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
},
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Test workflow’": {
"main": [
[
{
"node": "Get URLs with Missing Base Images",
"type": "main",
"index": 0
}
]
]
}
}