File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -131,19 +131,24 @@ export const getDefaultScreenshotTest = ({
131131
132132 await gotoPage ( page , path , lvl1 , fixedHeight ) ;
133133
134- // Target the DBBreadcrumb section to avoid page-level layout noise
134+ // Prefer scoping to the DBBreadcrumb section when present; otherwise fallback to default page
135135 const breadcrumbSection = page
136136 . getByRole ( 'heading' , { name : 'DBBreadcrumb' , level : 1 } )
137137 . locator ( 'xpath=ancestor::section[1]' ) ;
138138
139- // Ensure section is present and stable
140- await expect ( breadcrumbSection ) . toBeVisible ( ) ;
139+ let target = breadcrumbSection ;
140+ try {
141+ await expect ( breadcrumbSection ) . toBeVisible ( { timeout : 2000 } ) ;
142+ } catch {
143+ // Breadcrumb section not found for non-breadcrumb showcases; use full main content
144+ target = page . locator ( 'main' ) ;
145+ }
141146
142147 if ( preScreenShot ) {
143148 await preScreenShot ( page , project ) ;
144149 }
145150
146- await expect ( breadcrumbSection ) . toHaveScreenshot ( config ) ;
151+ await expect ( target ) . toHaveScreenshot ( config ) ;
147152 } ) ;
148153} ;
149154
You can’t perform that action at this time.
0 commit comments