硒C# - 无法点击与XLink元素上:href属性 [英] Selenium C# - Unable to click on element with xlink:href attribute
问题描述
我是相当新的硒为C#。我想点击℃之间的元素; SVG>
标签(如下图所示)。我曾尝试以下内容:
I am fairly new to Selenium for C#. I want to click on the element between the <svg>
tag (image below). I have tried the following :
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#,而是从 Nightwatchjs 。我们使用< SVG>
的图标和我选择<使用的XLink:HREF =/ SVG的图标/ sprite.stack。 SVG#排序升序>< /使用>
这个CSS选择器元素:
I'm not using Selenium from C#, but from Nightwatchjs. We're using <svg>
for icons and I select the <use xlink:href="/svg-icons/sprite.stack.svg#sort-ascending"></use>
element with this css selector:
使用[* | HREF =/ SVG-图标/ sprite.stack.svg#排序升序]
'use[*|href="/svg-icons/sprite.stack.svg#sort-ascending"]'
我猜这也从C#的作品。
I would guess this also works from C#.
这篇关于硒C# - 无法点击与XLink元素上:href属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!