Selenium 查找颜色的xpath

Selenium 查找颜色的xpath,selenium,selenium-webdriver,xpath,Selenium,Selenium Webdriver,Xpath,查找与背景颜色相关的XPath <div style="margin-right: 8px; position: relative; width: 8px; height: 8px; border-radius: 50%; display: inline-block; background-color: #f04d3b;"></div> 背景色不是属性,而是样式属性中的属性。因此,您必须更改xpath,如下所示 //div[@class="jqx-grid-cell-l

查找与背景颜色相关的XPath

<div style="margin-right: 8px; position: relative; width: 8px; height: 8px; border-radius: 50%; display: inline-block; background-color: #f04d3b;"></div>

背景色
不是属性,而是样式属性中的属性。因此,您必须更改xpath,如下所示

//div[@class="jqx-grid-cell-left-align"]/div[contains(@style(),'#f04d3b')] //div[@class="jqx-grid-cell-left-align"]//div[contains(@style,'background-color: #f04d3b')]

如果您认为问题已解决,请单击左侧“向下投票”按钮下方的空心复选标记,接受答案。
//div[@class="jqx-grid-cell-left-align"]/div[contains(@style(),'#f04d3b')] //div[@class="jqx-grid-cell-left-align"]//div[contains(@style,'background-color: #f04d3b')]