.net - 尝试通过 xlink:href 属性查找元素时出现 InvalidSelectorException
问题描述
我试图找到这样的元素:
<use xlink:href="site.org/path/action#edit"></use>
通过使用此选择器的给定属性:
public static By ElementsSelector { get; set; } = By.CssSelector(@"use[xlink:href='site.org/path/action#edit']");
我通过以下方式找到元素:
Driver.FindElements(EditProfilePage.ElementsSelector)[0].Click();
但我得到一个例外:
OpenQA.Selenium.InvalidSelectorException: 'invalid selector: An invalid or illegal selector was specified
(Session info: chrome=78.0.3904.87)'
问题:如何找到具有给定xlink:href
属性的元素?
解决方案
尝试不@
使用 css 选择器:
public static By ElementsSelector { get; set; } = By.CssSelector("use[xlink:href='site.org/path/action#edit']");
推荐阅读
- kotlin - Kotlin 空指针异常
- c++ - 为什么命令不执行?
- javascript - NgRx Effects 使用无限循环使 Angular 应用程序崩溃
- android - Cloud Firestore / Firebase 带宽非常高
- ios - 有没有人可以清楚地将 PKDrawing 呈现为 PDF 的好方法?
- python - 除了 fig.show() 还有其他功能可以显示图形吗?
- smartcard - 尝试使用 ICAO 9303 BAC 从 National eID (T=0) 读取数据
- amazon-web-services - 使用 AWS CDK 部署后如何执行数据库架构迁移?
- javascript - 即使组件未呈现,Vue.js也会出错
- javascript - TypeError:room.map 不是函数:ReactJS