[Python] TypeError: Controller.action() missing 1 required positional argument: 'self' on...

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    I have an AI Agent for which i have written a controller using Python 3.13 and Playwright.

    @Controller.action(description='Get attribute and url of the page')
    async def get_attr_url(self, browser: BrowserSession):
    page = await browser.get_current_page()
    current_url = page.url
    some_attribute = await page.get_by_text('swwg labs').get_attribute('class')
    print(current_url)
    return ActionResult(extracted_content = f'The current URL is {current_url} and the attribute is {some_attribute}')


    i call them as follows :

    controller = await Controller(output_model=CheckoutResults) //CheckoutResults-its another class.


    i have tried two different ways with same results . please help.

    1. class Controller:
    @Controller.action(description='Get attribute and url of the page')
    async def get_attr_url(self, browser: BrowserSession):
    page = await browser.get_current_page()
    current_url = page.url
    some_attribute = await page.get_by_text('swwg labs').get_attribute('class')
    print(current_url)
    return ActionResult(extracted_content = f'The current URL is {current_url} and the attribute is {some_attribute}')


    2. class Controller:
    @staticmethod
    @Controller.action(description='Get attribute and url of the page')
    async def get_attr_url(self, browser: BrowserSession):
    page = await browser.get_current_page()
    current_url = page.url
    some_attribute = await page.get_by_text('swwg labs').get_attribute('class')
    print(current_url)
    return ActionResult(extracted_content = f'The current URL is {current_url} and the attribute is {some_attribute}')


    For all i get the same results:

    TypeError: Controller.action() missing 1 required positional argument: 'self'


    Thank you

    Continue reading...

Compartilhe esta Página