Don't interact with fields that are already filled in (#183)

This commit is contained in:
Kerem Yilmaz
2024-04-12 20:05:25 -07:00
committed by GitHub
parent 3ea46b93cf
commit 7b1c1d5a02
4 changed files with 13 additions and 5 deletions

View File

@@ -143,6 +143,11 @@ async def handle_input_text_action(
) -> list[ActionResult]:
xpath = await validate_actions_in_dom(action, page, scraped_page)
locator = page.locator(f"xpath={xpath}")
current_text = await locator.input_value()
if current_text == action.text:
return [ActionSuccess()]
await locator.clear()
text = get_actual_value_of_parameter_if_secret(task, action.text)
await locator.fill(text, timeout=SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS)
@@ -313,6 +318,9 @@ async def handle_select_option_action(
)
return [ActionFailure(Exception(f"Cannot handle SelectOptionAction on a non-listbox element"))]
current_text = await locator.input_value()
if current_text == action.option.label:
return ActionSuccess()
try:
# First click by label (if it matches)
await page.click(f"xpath={xpath}", timeout=SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS)