(剧作家Async)如何修复:' attributeError:' coroutine'对象没有属性' inner_text' '

发布于 2025-02-03 04:26:34 字数 478 浏览 3 评论 0原文

我已经写了一个异步的剧作作者函数,但我不知道如何使用等待将此分配放入我的功能中。 这是导致我错误的代码行:

country = await feedback.query_selector('[class="user-country"]').inner_text()

这是我在控制台中获得错误的错误:

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

感谢您的任何帮助。 谢谢 !

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('[class="user-country"]').inner_text()

This is what I get in my console as error :

    country = await feedback.query_selector('[class="user-country"]').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 !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林很绿却致人迷途 2025-02-10 04:26:34

它应该是:等待(等待feathback.query_selector('[class =“ user-country”]'))。innion_text()。但是我们劝阻使用ElementHandles,请参阅此处: htttps://playwright.dev/ DOCS/NEXT/定位器#定位器-VS-ElementHandle

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文