Skip to content

Commit 0cd308b

Browse files
author
maebahesioru
committed
fix: improve parameter setting and submission reliability
- _set_parameter_with_retry: use Ctrl+A instead of select_text for reliable full selection in Angular spinbuttons - submit_prompt: if shortcuts fail but response already started, treat as success instead of attempting button click (avoids 500 errors)
1 parent 52a9cbe commit 0cd308b

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/browser/page_controller.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,17 @@ def extract_float(s):
598598
await asyncio.sleep(DELAY_AFTER_FILL)
599599
await locator.press('Tab')
600600
elif attempt == 1:
601-
strategy_name = "Standard Fill"
602-
await locator.focus()
603-
await locator.select_text()
604-
await locator.fill(str(target_value))
601+
strategy_name = "Ctrl+A Fill"
602+
await locator.click()
603+
await locator.press('Control+a')
604+
await locator.type(str(target_value), delay=30)
605605
await locator.press('Tab')
606606
await asyncio.sleep(DELAY_AFTER_FILL)
607607
await locator.dispatch_event('change')
608608
else:
609609
strategy_name = "Select & Type"
610610
await locator.focus()
611-
await locator.select_text()
611+
await locator.press('Control+a')
612612
await locator.press('Backspace')
613613
await asyncio.sleep(SLEEP_TICK)
614614
await locator.type(str(target_value), delay=50)
@@ -1093,9 +1093,14 @@ async def submit_prompt(self, prompt: str, image_list: List, check_client_discon
10931093
await asyncio.sleep(SLEEP_TICK)
10941094
submitted_successfully = await self._try_shortcut_submit(prompt_textarea_locator, check_client_disconnected)
10951095
if not submitted_successfully:
1096-
self.logger.info(f'[{self.req_id}] 快捷键提交失败,尝试点击提交按钮...')
1097-
await click_element(self.page, submit_button_locator, 'Submit Button', self.req_id, internal_timeout=10000)
1098-
self.logger.info(f'[{self.req_id}] 提交按钮点击完成。')
1096+
# Check if response already started (submission may have succeeded despite verification failure)
1097+
response_container = self.page.locator(RESPONSE_CONTAINER_SELECTOR)
1098+
if await response_container.count() > 0 and await response_container.last.is_visible(timeout=2000):
1099+
self.logger.info(f'[{self.req_id}] 快捷键验证失败但响应已开始,视为提交成功。')
1100+
else:
1101+
self.logger.info(f'[{self.req_id}] 快捷键提交失败,尝试点击提交按钮...')
1102+
await click_element(self.page, submit_button_locator, 'Submit Button', self.req_id, internal_timeout=10000)
1103+
self.logger.info(f'[{self.req_id}] 提交按钮点击完成。')
10991104
await self._check_disconnect(check_client_disconnected, '提交后')
11001105

11011106
except Exception as e_input_submit:

0 commit comments

Comments
 (0)