|
| 1 | +*** Settings *** |
| 2 | +Library SeleniumLibrary |
| 3 | +Library percy.robot_library.PercyLibrary |
| 4 | +Library Collections |
| 5 | + |
| 6 | +Suite Setup Open Test Browser |
| 7 | +Suite Teardown Close All Browsers |
| 8 | + |
| 9 | +*** Keywords *** |
| 10 | +Open Test Browser |
| 11 | + Open Browser https://example.com chrome options=add_argument("--headless") |
| 12 | + |
| 13 | +*** Test Cases *** |
| 14 | + |
| 15 | +# =================================================================== |
| 16 | +# BASIC SNAPSHOTS |
| 17 | +# =================================================================== |
| 18 | + |
| 19 | +Basic Snapshot |
| 20 | + [Documentation] Simplest snapshot — just a name |
| 21 | + Percy Snapshot Basic - Example.com |
| 22 | + |
| 23 | +Named Snapshot After Navigation |
| 24 | + [Documentation] Navigate and take snapshot |
| 25 | + Go To https://example.com |
| 26 | + Percy Snapshot Navigation - After GoTo |
| 27 | + |
| 28 | +Multiple Snapshots Same Page |
| 29 | + [Documentation] Multiple snapshots of the same page |
| 30 | + Go To https://example.com |
| 31 | + Percy Snapshot Multi - First |
| 32 | + Percy Snapshot Multi - Second |
| 33 | + |
| 34 | +# =================================================================== |
| 35 | +# RESPONSIVE WIDTHS |
| 36 | +# =================================================================== |
| 37 | + |
| 38 | +Single Width Mobile |
| 39 | + [Documentation] Snapshot at mobile width only |
| 40 | + Percy Snapshot Width - Mobile 375 widths=375 |
| 41 | + |
| 42 | +Multiple Widths |
| 43 | + [Documentation] Snapshot at mobile, tablet, desktop |
| 44 | + Percy Snapshot Width - All Breakpoints widths=375,768,1280 |
| 45 | + |
| 46 | +# =================================================================== |
| 47 | +# MIN HEIGHT |
| 48 | +# =================================================================== |
| 49 | + |
| 50 | +Min Height |
| 51 | + [Documentation] Snapshot with minimum height |
| 52 | + Percy Snapshot MinHeight - 1024 min_height=1024 |
| 53 | + |
| 54 | +Widths Plus Min Height |
| 55 | + [Documentation] Combine widths and min height |
| 56 | + Percy Snapshot Widths+Height widths=375,1280 min_height=1500 |
| 57 | + |
| 58 | +# =================================================================== |
| 59 | +# PERCY CSS |
| 60 | +# =================================================================== |
| 61 | + |
| 62 | +Percy CSS Hide Heading |
| 63 | + [Documentation] Hide the h1 heading |
| 64 | + Percy Snapshot CSS - Hide H1 percy_css=h1 { display: none !important; } |
| 65 | + |
| 66 | +Percy CSS Custom Background |
| 67 | + [Documentation] Change background color |
| 68 | + Percy Snapshot CSS - Background percy_css=body { background-color: #f0f0f0 !important; } |
| 69 | + |
| 70 | +# =================================================================== |
| 71 | +# SCOPED SNAPSHOTS |
| 72 | +# =================================================================== |
| 73 | + |
| 74 | +Scoped To Body Div |
| 75 | + [Documentation] Capture only the main content div |
| 76 | + Percy Snapshot Scope - Body Div scope=body > div |
| 77 | + |
| 78 | +Scope With Percy CSS |
| 79 | + [Documentation] Combine scope and CSS injection |
| 80 | + Percy Snapshot Scope+CSS scope=body > div percy_css=p { color: blue !important; } |
| 81 | + |
| 82 | +# =================================================================== |
| 83 | +# RENDERING OPTIONS |
| 84 | +# =================================================================== |
| 85 | + |
| 86 | +JavaScript Enabled |
| 87 | + [Documentation] Snapshot with JS enabled in Percy rendering |
| 88 | + Percy Snapshot JS - Enabled enable_javascript=True |
| 89 | + |
| 90 | +Layout Mode |
| 91 | + [Documentation] Layout comparison mode |
| 92 | + Percy Snapshot Layout - Basic enable_layout=True |
| 93 | + |
| 94 | +Shadow DOM Disabled |
| 95 | + [Documentation] Snapshot without Shadow DOM capture |
| 96 | + Percy Snapshot ShadowDOM - Disabled disable_shadow_dom=True |
| 97 | + |
| 98 | +# =================================================================== |
| 99 | +# LABELS / TAGS |
| 100 | +# =================================================================== |
| 101 | + |
| 102 | +Single Label |
| 103 | + [Documentation] Snapshot with one label |
| 104 | + Percy Snapshot Labels - Single labels=smoke-test |
| 105 | + |
| 106 | +Multiple Labels |
| 107 | + [Documentation] Snapshot with multiple labels |
| 108 | + Percy Snapshot Labels - Multiple labels=regression,homepage,v2 |
| 109 | + |
| 110 | +Labels With Widths |
| 111 | + [Documentation] Labels combined with responsive widths |
| 112 | + Percy Snapshot Labels+Widths labels=responsive,cross-browser widths=375,768,1280 |
| 113 | + |
| 114 | +# =================================================================== |
| 115 | +# TEST CASE METADATA |
| 116 | +# =================================================================== |
| 117 | + |
| 118 | +Test Case ID |
| 119 | + [Documentation] Snapshot with test case identifier |
| 120 | + Percy Snapshot TestCase - TC001 test_case=TC-001-homepage |
| 121 | + |
| 122 | +# =================================================================== |
| 123 | +# IGNORE REGIONS |
| 124 | +# =================================================================== |
| 125 | + |
| 126 | +Ignore Region By CSS |
| 127 | + [Documentation] Create ignore region using CSS selector |
| 128 | + ${region}= Create Percy Region algorithm=ignore element_css=h1 |
| 129 | + Percy Snapshot Region - Ignore CSS regions=${{json.dumps([${region}])}} |
| 130 | + |
| 131 | +Ignore Region By XPath |
| 132 | + [Documentation] Create ignore region using XPath |
| 133 | + ${region}= Create Percy Region algorithm=ignore element_xpath=//h1 |
| 134 | + Percy Snapshot Region - Ignore XPath regions=${{json.dumps([${region}])}} |
| 135 | + |
| 136 | +# =================================================================== |
| 137 | +# CONSIDER REGIONS |
| 138 | +# =================================================================== |
| 139 | + |
| 140 | +Consider Region Standard |
| 141 | + [Documentation] Standard algorithm with diff sensitivity |
| 142 | + ${region}= Create Percy Region algorithm=standard element_css=body > div diff_sensitivity=5 |
| 143 | + Percy Snapshot Region - Standard regions=${{json.dumps([${region}])}} |
| 144 | + |
| 145 | +IntelliIgnore Region |
| 146 | + [Documentation] IntelliIgnore with carousel detection |
| 147 | + ${region}= Create Percy Region algorithm=intelliignore element_css=body > div carousels_enabled=True |
| 148 | + Percy Snapshot Region - IntelliIgnore regions=${{json.dumps([${region}])}} |
| 149 | + |
| 150 | +# =================================================================== |
| 151 | +# MULTIPLE REGIONS |
| 152 | +# =================================================================== |
| 153 | + |
| 154 | +Mixed Ignore And Consider Regions |
| 155 | + [Documentation] Combine ignore and consider regions |
| 156 | + ${ignore}= Create Percy Region algorithm=ignore element_css=h1 |
| 157 | + ${consider}= Create Percy Region algorithm=standard element_css=p diff_sensitivity=8 |
| 158 | + Percy Snapshot Region - Mixed regions=${{json.dumps([${ignore}, ${consider}])}} |
| 159 | + |
| 160 | +# =================================================================== |
| 161 | +# RESPONSIVE CAPTURE |
| 162 | +# =================================================================== |
| 163 | + |
| 164 | +Responsive Capture |
| 165 | + [Documentation] Responsive capture resizes browser per width |
| 166 | + Percy Snapshot Responsive - Basic responsive_snapshot_capture=True |
| 167 | + |
| 168 | +# =================================================================== |
| 169 | +# ALL OPTIONS COMBINED |
| 170 | +# =================================================================== |
| 171 | + |
| 172 | +All Options Combined |
| 173 | + [Documentation] Every option in a single snapshot call |
| 174 | + ${ignore}= Create Percy Region algorithm=ignore element_css=h1 padding=5 |
| 175 | + Percy Snapshot Full Options - Everything |
| 176 | + ... widths=375,768,1280 |
| 177 | + ... min_height=1024 |
| 178 | + ... percy_css=a { text-decoration: none !important; } |
| 179 | + ... enable_javascript=True |
| 180 | + ... enable_layout=True |
| 181 | + ... labels=full-test,regression,v2 |
| 182 | + ... test_case=TC-999-all-options |
| 183 | + ... regions=${{json.dumps([${ignore}])}} |
| 184 | + |
| 185 | +# =================================================================== |
| 186 | +# UTILITY KEYWORDS |
| 187 | +# =================================================================== |
| 188 | + |
| 189 | +Percy Is Running Returns True |
| 190 | + [Documentation] Verify Percy Is Running keyword works |
| 191 | + ${running}= Percy Is Running |
| 192 | + Should Be True ${running} |
| 193 | + |
| 194 | +Conditional Snapshot |
| 195 | + [Documentation] Take snapshot only if Percy is running |
| 196 | + ${running}= Percy Is Running |
| 197 | + Run Keyword If ${running} Percy Snapshot Conditional - If Running |
0 commit comments