@@ -50,51 +50,41 @@ class VolViewPage extends Page {
5050 await browser . waitUntil (
5151 async ( ) => {
5252 try {
53- // Query views fresh each time to avoid stale references
54- const views = await this . views ;
55- const viewCount = await views . length ;
53+ // Query views once per iteration to avoid multiple queries that could become stale
54+ const currentViews = await this . views ;
55+ const viewCount = await currentViews . length ;
5656
5757 if ( viewCount === 0 ) {
5858 return false ;
5959 }
6060
61- // Check if at least one view has real dimensions
62- const freshViews = await this . views ;
63- const freshCount = await freshViews . length ;
64-
65- const viewChecks = Array . from ( { length : viewCount } , ( _ , i ) => i ) ;
66-
67- const results = await Promise . all (
68- viewChecks . map ( async ( i ) => {
69- if ( i >= freshCount ) {
70- return false ;
61+ // Check each view's dimensions in a single pass
62+ const viewPromises = currentViews . map ( async ( view ) => {
63+ try {
64+ // Get attributes directly from the element reference
65+ const width = await view . getAttribute ( 'width' ) ;
66+ const height = await view . getAttribute ( 'height' ) ;
67+
68+ if ( width && height ) {
69+ const w = parseInt ( width , 10 ) ;
70+ const h = parseInt ( height , 10 ) ;
71+ // Canvas should have real dimensions, not be a 1x1 placeholder
72+ // Accept any size > 10 as a real view
73+ return w > 10 && h > 10 ;
7174 }
75+ return false ;
76+ } catch ( err ) {
77+ // Element may have been removed/recreated - that's ok, we'll retry
78+ return false ;
79+ }
80+ } ) ;
7281
73- try {
74- const view = freshViews [ i ] ;
75- const [ width , height ] = await Promise . all ( [
76- view . getAttribute ( 'width' ) . catch ( ( ) => null ) ,
77- view . getAttribute ( 'height' ) . catch ( ( ) => null ) ,
78- ] ) ;
79-
80- if ( width && height ) {
81- const w = parseInt ( width , 10 ) ;
82- const h = parseInt ( height , 10 ) ;
83- // Canvas should have real dimensions, not be a 1x1 placeholder
84- // Accept any size > 10 as a real view
85- return w > 10 && h > 10 ;
86- }
87- return false ;
88- } catch ( err ) {
89- // Handle stale element errors
90- return false ;
91- }
92- } )
93- ) ;
82+ const results = await Promise . all ( await viewPromises ) ;
9483
84+ // At least one view must have real dimensions
9585 return results . some ( ( result ) => result ) ;
9686 } catch ( error ) {
97- // Log but don't throw - let it retry
87+ // DOM may be updating, retry on next iteration
9888 return false ;
9989 }
10090 } ,
0 commit comments