Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
store xpath as root level attribute of action (#3654)
Shuchang Zheng40d127de58ae
diff --git a/skyvern/core/script_generations/skyvern_page.py b/skyvern/core/script_generations/skyvern_page.pyindex 32a75c68c..47b9d6369 100644--- a/skyvern/core/script_generations/skyvern_page.py+++ b/skyvern/core/script_generations/skyvern_page.py@@ -346,6 +346,9 @@ class SkyvernPage:# Create action record. TODO: store more action fieldskwargs = kwargs or {}# we're using "value" instead of "text" for input text actions interface+ xpath = kwargs.get("xpath")+ if action_type == ActionType.CLICK:+ xpath = call_result or xpathtext = Noneselect_option = Noneresponse: str | None = kwargs.get("response")@@ -376,6 +379,7 @@ class SkyvernPage:option=select_option,file_url=file_url,response=response,+ xpath=xpath,created_by="script",)data_extraction_goal = None@@ -461,7 +465,7 @@ class SkyvernPage:######### Public Interfaces #########@action_wrap(ActionType.CLICK)- async def click(self, xpath: str, intention: str | None = None, data: str | dict[str, Any] | None = None) -> None:+ async def click(self, xpath: str, intention: str | None = None, data: str | dict[str, Any] | None = None) -> str:"""Click an element identified by ``xpath``.When ``intention`` and ``data`` are provided a new click action is@@ -504,6 +508,7 @@ class SkyvernPage:locator = self.page.locator(f"xpath={new_xpath}")await locator.click(timeout=5000)+ return new_xpath@action_wrap(ActionType.INPUT_TEXT)async def fill(@@ -755,9 +760,7 @@ class SkyvernPage:return@action_wrap(ActionType.SOLVE_CAPTCHA)- async def solve_captcha(- self, xpath: str, intention: str | None = None, data: str | dict[str, Any] | None = None- ) -> None:+ async def solve_captcha(self, intention: str | None = None, data: str | dict[str, Any] | None = None) -> None:context = skyvern_context.current()if not context or not context.organization_id or not context.task_id or not context.step_id:await asyncio.sleep(30)diff --git a/skyvern/webeye/actions/actions.py b/skyvern/webeye/actions/actions.pyindex 6f10ce73c..d03b37660 100644--- a/skyvern/webeye/actions/actions.py+++ b/skyvern/webeye/actions/actions.py@@ -72,6 +72,7 @@ class Action(BaseModel):skyvern_element_hash: str | None = Noneskyvern_element_data: dict[str, Any] | None = Nonetool_call_id: str | None = None+ xpath: str | None = None# DecisiveAction (CompleteAction, TerminateAction) fieldserrors: list[UserDefinedError] | None = None@@ -130,6 +131,8 @@ class Action(BaseModel):raise ValueError("Invalid action data")def get_xpath(self) -> str | None:+ if self.xpath:+ return self.xpathif not self.skyvern_element_data:return Noneif "xpath" in self.skyvern_element_data: