【发布时间】:2021-06-11 09:44:32
【问题描述】:
我的目标是在包含特定文本的网页中找到所有 HREF 链接。 使用我在“查找元素”中测试过的 Chrome DevTools:
[href*='photo/?fbid']
它可以很好地返回它们。
当我尝试将它包含在机器人框架脚本中时:
${elements}= Get WebElements xpath://[href*='photo/?fbid']
FOR ${element} IN @{elements}
Log ${element.text}
Log ${element}
END
我收到错误消息:
InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //[href*='photo/?fbid'] because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//[href*='photo/?fbid']' is not a valid XPath expression.
(Session info: chrome=86.0.4240.111)
我尝试查看文档,但我不明白什么是正确的语法。 任何帮助表示赞赏。 谢谢
【问题讨论】:
标签: selenium xpath selenium-chromedriver robotframework