Selenium 使用特殊标记名和属性-量角器定位元素

Selenium 使用特殊标记名和属性-量角器定位元素,selenium,automation,protractor,Selenium,Automation,Protractor,我在使用XPath(或其他定位器)定位此元素(以及其他类似元素)时遇到问题,我尝试使用(路径)作为标记名,但我无法,我想定位(stroke=“#929292”)——这是块的颜色——以在我的自动化测试场景中使用 Video player yonhub TeamEdge detection yonhub TeamVideo vieweryonhub Team您正在尝试与元素交互。为了访问该元素,您需要使用以下xpath 请尝试以下xpath: //*[name()='g']/*[@stroke='

我在使用XPath(或其他定位器)定位此元素(以及其他类似元素)时遇到问题,我尝试使用(路径)作为标记名,但我无法,我想定位(stroke=“#929292”)——这是块的颜色——以在我的自动化测试场景中使用


Video player yonhub TeamEdge detection yonhub TeamVideo vieweryonhub Team
您正在尝试与元素交互。为了访问该元素,您需要使用以下xpath

请尝试以下xpath:

//*[name()='g']/*[@stroke='#929292']


您还可以使用css选择器:


const needeleme=$('g[stroke=“#929292”]”)

您所说的“想要定位(stroke=“#929292”)-这是块的颜色”是什么意思?ElementFinder只表示页面上的单个元素。您是说要验证元素的样式属性吗?虽然有效,但仍定位到许多元素,如何定位此特定元素?@kiko您需要使用父标记提供更相关的HTML。以便检查如何使其唯一。
//*[local-name()='g']/path[@stroke='#929292']
//*[name()='g']/path[@stroke='#929292']
//*[local-name()='g']/*[@stroke='#929292']