XPath选择包含文本的链接?

时间:2016-05-30 19:41:51

标签: html xml selenium xpath selenium-webdriver

我尝试使用此XPath:

//*[contains(normalize-space(text()),'Jira')]

也尝试过:

//*[contains(text(),'Jira')]

在下面的HTML示例中,文本“Jira”之前和之后有空格。我无法点击链接:

<a href="#/crm/usergroup-edit?id=572a3c84e4b07f6189958700" 
   ng-repeat="gp in groups | filter : userGroupSearch | orderBy:'-name':1" 
   class="ng-scope">
    <div class="inventoryPanel" ng-style="myStyle" style="width: 15.8%;">
        <h4 class="ng-binding">
            <div class="groupIcon G">
                <div class="text ng-binding">P</div>
            </div>Jira
         </h4>
    </div>
 </a>

1 个答案:

答案 0 :(得分:1)

以下XPath将选择其字符串值包含a子字符串的所有Jira个元素:

//a[contains(.,'Jira')]