@@ -90,8 +90,11 @@ export async function uploadSocialPreviewViaBrowser(
9090 const editClicked = await page . evaluate ( ( ) => {
9191 const summaries = document . querySelectorAll ( 'summary, button' )
9292 for ( const el of summaries ) {
93- if ( el . textContent ?. includes ( 'Edit' ) && el . closest ( '[class*="social"]' ) ) {
94- ; ( el as HTMLElement ) . click ( )
93+ if (
94+ el . textContent ?. includes ( 'Edit' ) &&
95+ el . closest ( '[class*="social"]' )
96+ ) {
97+ ( el as HTMLElement ) . click ( )
9598 return true
9699 }
97100 }
@@ -102,7 +105,7 @@ export async function uploadSocialPreviewViaBrowser(
102105 const parent = label . closest ( 'div' )
103106 const btn = parent ?. querySelector ( 'summary, button' )
104107 if ( btn ) {
105- ; ( btn as HTMLElement ) . click ( )
108+ ( btn as HTMLElement ) . click ( )
106109 return true
107110 }
108111 }
@@ -132,13 +135,17 @@ export async function uploadSocialPreviewViaBrowser(
132135 // Look for and click save button
133136 const buttons = await page . $$ ( 'button[type="submit"], button' )
134137 for ( const button of buttons ) {
135- const text = await button . evaluate (
136- el => el . textContent ?. toLowerCase ( ) || ''
137- )
138- if ( text . includes ( 'save' ) || text . includes ( 'update' ) ) {
139- await button . click ( )
140- await delay ( 2000 )
141- break
138+ try {
139+ const text = await button . evaluate (
140+ el => el . textContent ?. toLowerCase ( ) || ''
141+ )
142+ if ( text . includes ( 'save' ) || text . includes ( 'update' ) ) {
143+ await button . click ( )
144+ await delay ( 2000 )
145+ break
146+ }
147+ } catch {
148+ // Skip buttons that aren't clickable
142149 }
143150 }
144151
@@ -215,7 +222,7 @@ export async function uploadAllViaBrowser(
215222 el . textContent ?. includes ( 'Edit' ) &&
216223 el . closest ( '[class*="social"]' )
217224 ) {
218- ; ( el as HTMLElement ) . click ( )
225+ ( el as HTMLElement ) . click ( )
219226 return true
220227 }
221228 }
@@ -226,7 +233,7 @@ export async function uploadAllViaBrowser(
226233 const parent = label . closest ( 'div' )
227234 const btn = parent ?. querySelector ( 'summary, button' )
228235 if ( btn ) {
229- ; ( btn as HTMLElement ) . click ( )
236+ ( btn as HTMLElement ) . click ( )
230237 return true
231238 }
232239 }
@@ -256,13 +263,17 @@ export async function uploadAllViaBrowser(
256263 // Look for and click save button
257264 const buttons = await page . $$ ( 'button[type="submit"], button' )
258265 for ( const button of buttons ) {
259- const text = await button . evaluate (
260- el => el . textContent ?. toLowerCase ( ) || ''
261- )
262- if ( text . includes ( 'save' ) || text . includes ( 'update' ) ) {
263- await button . click ( )
264- await delay ( 2000 )
265- break
266+ try {
267+ const text = await button . evaluate (
268+ el => el . textContent ?. toLowerCase ( ) || ''
269+ )
270+ if ( text . includes ( 'save' ) || text . includes ( 'update' ) ) {
271+ await button . click ( )
272+ await delay ( 2000 )
273+ break
274+ }
275+ } catch {
276+ // Skip buttons that aren't clickable
266277 }
267278 }
268279
0 commit comments