(剧作家Async)如何修复:' attributeError:' coroutine'对象没有属性' inner_text' '
我已经写了一个异步的剧作作者函数,但我不知道如何使用等待
将此分配放入我的功能中。 这是导致我错误的代码行:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该是:
等待(等待feathback.query_selector('[class =“ user-country”]'))。innion_text()
。但是我们劝阻使用ElementHandles,请参阅此处: htttps://playwright.dev/ DOCS/NEXT/定位器#定位器-VS-ElementHandleIt 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