longer wait time to load dropdown when there is an onclick attr (#3743)

This commit is contained in:
LawyZheng
2025-10-17 00:45:42 +08:00
committed by GitHub
parent edcd0b0e57
commit 0a993f18ea
2 changed files with 23 additions and 1 deletions

View File

@@ -648,6 +648,7 @@ async def handle_click_action(
incremental_scraped = IncrementalScrapePage(skyvern_frame=skyvern_frame)
await incremental_scraped.start_listen_dom_increment(await skyvern_element.get_element_handler())
has_onclick_attr = await skyvern_element.has_attr("onclick", mode="static")
results = await chain_click(
task,
scraped_page,
@@ -663,6 +664,12 @@ async def handle_click_action(
return results
try:
if has_onclick_attr:
LOG.info(
"The element has onclick attribute, waiting for 1 second to load new elements", action=action
)
await skyvern_frame.safe_wait_for_animation_end(before_wait_sec=1)
if sequential_click_result := await handle_sequential_click_for_dropdown(
action=action,
action_history=results,
@@ -1141,6 +1148,7 @@ async def handle_input_text_action(
and skyvern_element.get_tag_name() == InteractiveElement.INPUT
and not await skyvern_element.is_raw_input()
):
has_onclick_attr = await skyvern_element.has_attr("onclick", mode="static")
await skyvern_element.scroll_into_view()
# press arrowdown to watch if there's any options popping up
await incremental_scraped.start_listen_dom_increment(await skyvern_element.get_element_handler())
@@ -1166,7 +1174,12 @@ async def handle_input_text_action(
action=action,
)
await skyvern_frame.safe_wait_for_animation_end()
wait_sec = 0
if has_onclick_attr:
LOG.info("The element has onclick attribute, waiting for 1 second to load new elements", action=action)
wait_sec = 1
await skyvern_frame.safe_wait_for_animation_end(before_wait_sec=wait_sec)
incremental_element = await incremental_scraped.get_incremental_element_tree(
clean_and_remove_element_tree_factory(
task=task, step=step, check_filter_funcs=[check_existed_but_not_option_element_in_dom_factory(dom)]

View File

@@ -323,6 +323,15 @@ class SkyvernElement:
return True
return False
async def has_attr(self, attr_name: str, mode: typing.Literal["auto", "dynamic", "static"] = "auto") -> bool:
value = await self.get_attr(attr_name, mode=mode)
# FIXME(maybe?): already parsed the value of "disabled", "readonly" into boolean.
# so the empty string values should be considered as FALSE value?
# maybe need to come back to change it?
if value:
return True
return False
def get_element_dict(self) -> dict:
return self.__static_element