1. 使用css选择器,指定特定属性时,不能直接采用浏览器中的形式:
ele.query_selector("[attr=value]")
会报错:
playwright._impl._api_types.Error: Evaluation failed: SyntaxError: The string did not match the expected pattern.
应该使用:
ele.query_selector("[attr='value']")
如:
ele.query_selector("css=[data-xh='0']")
本文介绍了在使用Playwright进行页面元素定位时,如何正确地使用CSS选择器来指定带有属性的元素。针对直接使用属性值作为选择器时出现的错误,文章提供了正确的解决方案。
858

被折叠的 条评论
为什么被折叠?



