【发布时间】:2016-11-30 10:14:35
【问题描述】:
我正在尝试通过以下方式获取 CSS 属性“内容”的值:
WebElement plusOrMinusSign = currentEntityTypeLevel1.findElement(
By.xpath("i[@class='tree-branch-head']::after"));
System.out.println(plusOrMinusSign.getCssValue("content"));
但是,我收到一个错误:The string 'i[@class='tree-branch-head']::after' is not a valid XPath expression.
似乎无法识别“::after”。
HTML:
<i class="tree-branch-head" ng-class="iBranchClass()" ng-click="selectNodeHead(node)">::after
</i>
CSS:
i:after {
content: "-";
}
知道如何获得“内容”的价值吗?
【问题讨论】:
-
试试
//i[@class='tree-branch-head']::after -
@Nikhil,我不熟悉在 selenium 项目中使用 javascript。你能给我一个指针/例子吗?
-
@Girish,“//”没有区别...
标签: css xpath selenium-webdriver pseudo-element