@@ -395,10 +395,16 @@ async def _adjust_google_search(self, request_params: Dict[str, Any], check_clie
395395 if (new_state == 'true' ) == should_enable_search :
396396 self .logger .info (f'[{ self .req_id } ] ✅ Google Search 已{ action } 。' )
397397 return
398- else :
399- self .logger .warning (f"[{ self .req_id } ] ⚠️ Google Search { action } 失敗 (嘗試 { attempt } ): '{ new_state } '" )
400- if attempt < max_retries :
401- await asyncio .sleep (DELAY_AFTER_TOGGLE )
398+ # Force via JS click on parent label
399+ await toggle_locator .evaluate ('el => (el.closest("label") || el).click()' )
400+ await asyncio .sleep (1.0 )
401+ new_state = await toggle_locator .get_attribute ('aria-checked' )
402+ if (new_state == 'true' ) == should_enable_search :
403+ self .logger .info (f'[{ self .req_id } ] ✅ Google Search 已{ action } (JS)。' )
404+ return
405+ self .logger .warning (f"[{ self .req_id } ] ⚠️ Google Search { action } 失敗 (嘗試 { attempt } ): '{ new_state } '" )
406+ if attempt < max_retries :
407+ await asyncio .sleep (DELAY_AFTER_TOGGLE )
402408 except Exception as e :
403409 if isinstance (e , ClientDisconnectedError ):
404410 raise
@@ -710,6 +716,7 @@ async def _adjust_stop_sequences(self, stop_sequences, page_params_cache: dict,
710716 if normalized_requested_stops :
711717 await expect_async (stop_input_locator ).to_be_visible (timeout = 5000 )
712718 for seq in normalized_requested_stops :
719+ await stop_input_locator .click (timeout = 3000 )
713720 await stop_input_locator .fill (seq , timeout = 5000 )
714721 await stop_input_locator .press ('Enter' , timeout = 5000 )
715722 await asyncio .sleep (DELAY_AFTER_FILL )
0 commit comments