Home > Enterprise >  (Playwright async ) How to fix :' AttributeError: 'coroutine' object has no attribute
(Playwright async ) How to fix :' AttributeError: 'coroutine' object has no attribute

Time:06-03

I have written a async playwright function but I don't know how to put this assignement into my function , using await. Here is the line of code that cause me error :

country = await feedback.query_selector('[]').inner_text()

This is what I get in my console as error :

    country = await feedback.query_selector('[]').inner_text()
AttributeError: 'coroutine' object has no attribute 'inner_text'
sys:1: RuntimeWarning: coroutine 'ElementHandle.query_selector' was never awaited

I would appreciate any help from you. Thank you !

CodePudding user response:

It should be: await (await feedback.query_selector('[]')).inner_text(). But we discourage from using ElementHandles, see here: https://playwright.dev/docs/next/locators#locator-vs-elementhandle

  • Related