Skip to content

Commit

Permalink
input type button (#1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
LawyZheng authored Oct 28, 2024
1 parent 8e8f41d commit 64def7c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions skyvern/webeye/actions/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,17 @@ async def handle_select_option_action(
LOG.info(
"SelectOptionAction is on <select>",
action=action,
task_id=task.task_id,
step_id=step.step_id,
)
return await normal_select(action=action, skyvern_element=skyvern_element)

if await skyvern_element.is_checkbox():
LOG.info(
"SelectOptionAction is on <input> checkbox",
action=action,
task_id=task.task_id,
step_id=step.step_id,
)
check_action = CheckboxAction(element_id=action.element_id, is_checked=True)
return await handle_checkbox_action(check_action, page, scraped_page, task, step)
Expand All @@ -783,6 +787,19 @@ async def handle_select_option_action(
LOG.info(
"SelectOptionAction is on <input> radio",
action=action,
task_id=task.task_id,
step_id=step.step_id,
)
click_action = ClickAction(element_id=action.element_id)
return await chain_click(task, scraped_page, page, click_action, skyvern_element)

# FIXME: maybe there's a case where <input type="button"> could trigger dropdown menu?
if await skyvern_element.is_btn_input():
LOG.info(
"SelectOptionAction is on <input> button",
action=action,
task_id=task.task_id,
step_id=step.step_id,
)
click_action = ClickAction(element_id=action.element_id)
return await chain_click(task, scraped_page, page, click_action, skyvern_element)
Expand Down
8 changes: 8 additions & 0 deletions skyvern/webeye/utils/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ async def is_radio(self) -> bool:
button_type = await self.get_attr("type")
return button_type == "radio"

async def is_btn_input(self) -> bool:
tag_name = self.get_tag_name()
if tag_name != InteractiveElement.INPUT:
return False

input_type = await self.get_attr("type")
return input_type == "button"

async def is_raw_input(self) -> bool:
if self.get_tag_name() != InteractiveElement.INPUT:
return False
Expand Down

0 comments on commit 64def7c

Please sign in to comment.