Selenium C# – 无法使用xlink:href属性单击元素

对于C#来说,我是Selenium的新手。 我想点击标签之间的元素(下图)。 我尝试过以下方法:

  driver.FindElement(By.XPath("//use[@href='#events-widget']")).Click(); driver.FindElement(By.XPath("//use[@href='#events-widget'/]")).Click(); driver.FindElement(By.XPath("//use[@xlink:href='#events-widget']")).Click(); driver.FindElement(By.XPath("//use[@xlink:href='#events-widget']/")).Click(); driver.FindElement(By.LinkText("Events")).Click(); 

在此处输入图像描述

帮助将不胜感激:)

我没有使用C#中的Selenium,而是使用Nightwatchjs 。 我们使用作为图标,我用这个css选择器选择元素:

‘用[* | HREF = “/ SVG的图标/ sprite.stack.svg#排序升序”]’

我猜这也适用于C#。