Skip to content

Website Cache? #7

@JunzheJosephZhu

Description

@JunzheJosephZhu
async def execute_browser_action(
        self, browser_action: BrowserAction
    ) -> Tuple[str, str]:
        action = browser_action.task_with_action.actions_to_be_performed[0]
        print(f"{YELLOW}[DEBUG] Executing browser action: {action.type}{RESET}")

        if action.type == ActionType.GOTO_URL:
            print(f"{CYAN}[DEBUG] Trying to go to url{RESET}")
            await openurl(url=action.website, timeout=action.timeout or 1)
            print(f"{CYAN}[DEBUG] Went to url{RESET}")
        elif action.type == ActionType.TYPE:
            entry = EnterTextEntry(
                query_selector=f"[mmid='{action.mmid}']",
                text=action.content,
            )
            await entertext(entry)
            # await wait_for_navigation()
            print(f"{CYAN}[DEBUG] Typed text into element{RESET}")
        elif action.type == ActionType.CLICK:
            await click(
                selector=f"[mmid='{action.mmid}']",
                wait_before_execution=action.wait_before_execution or 2,
            )
            print(f"{CYAN}[DEBUG] Clicked element{RESET}")
        elif action.type == ActionType.ENTER_TEXT_AND_CLICK:
            await enter_text_and_click(
                text_selector=f"[mmid='{action.text_element_mmid}']",
                text_to_enter=action.text_to_enter,
                click_selector=f"[mmid='{action.click_element_mmid}']",
                wait_before_click_execution=action.wait_before_click_execution or 2,
            )
            # await wait_for_navigation()
            print(f"{CYAN}[DEBUG] Entered text and clicked element{RESET}")

        try:
            new_dom = await self.get_current_dom()
        except Exception as e:
            print(f"{RED}[DEBUG] Error getting DOM after action: {e}{RESET}")
            new_dom = "Error: Unable to retrieve DOM"

        try:
            new_url = await self.get_current_url()
        except Exception as e:
            print(f"{RED}[DEBUG] Error getting URL after action: {e}{RESET}")
            new_url = "Error: Unable to retrieve URL"

        print(f"{GREEN}[DEBUG] After action execution - New URL: {new_url}{RESET}")
        return new_dom, new_url

This looks like it just simply uses the DOM as the state and doesnt really take the server state into account (like whats in the cart, etc). Is there somewhere else in the codebase that resets the browser to an old state before it searches its children nodes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions