如何找到css或xpath的下面元素

时间:2015-10-19 08:54:52

标签: css xpath

我有以下代码,想要找到css或xpath的元素。

<div class="arrowIconDiv" data-dojo-attach-point="arrowIconDiv">
<div class="i-arrow-double" data-dojo-attach-point="NavAreaExpander">  /div>
<div class="i-arrow-double-hover" data-dojo-attach-point="NavAreaExpanderHover"></div>

尝试了多项但无法找到并点击该元素。

(by.css(".arrowIconDiv"))
(by.css('[data-dojo-attach-point="arrowIconDiv"]'))
(by.xpath('.//div[@class="i-arrow-double-hover"][.="NavAreaExpanderHover"]'))

提前致谢

1 个答案:

答案 0 :(得分:0)

NavAreaExpanderHoverdata-dojo-attach-point属性的值,而不是div元素的内容。因此,不要在XPath中使用.,而是使用属性名称:

.//div[@class="i-arrow-double-hover" and @data-dojo-attach-point="NavAreaExpanderHover"]