Reputation: 83
Help me to find the xpath of an element, I want to find the with the @class="tipN button greenB" in the second [2] which has @class="middleNav"
<div id="rightSide">
<div class="topNav">
<style type="text/css">
<div class="resp">
<div class="titleArea">
<div class="wrapper">
<div class="pageTitle">
<div class="middleNav" data-bind="visible: showAllButtons" style="display: none;">
<a id="saveformtop" class="tipN button greenB" data-bind="click: SaveForm, visible: showGridButtons" original-title="Save Staff data" href="#" style="margin: 5px; display: none;" novalidate="novalidate">
<a class="tipN button greenB" original-title="Save Staff data" href="#" style="margin: 5px;" data-bind="click: SaveRestrictions, visible: showRestriction">
<a id="cancelbtntop" class="tipN button redB" original-title="Cancel all edits" data-bind="click:CancelForm, visible: showGridButtons" style="margin: 5px; display: none;">
<a class="tipN button redB" original-title="Cancel all edits" data-bind="click: CancelRestriction, visible: showRestriction" style="margin: 5px;">
<div class="clear"> </div>
</div>
<div class="middleNav" data-bind="visible: !showAllButtons()" style="">
<a id="cancelbtntop" class="tipN button redB" original-title="Cancel all edits" data-bind="click:CancelForm, visible: showGridButtons" style="margin: 5px; display: none;">
<img class="icon" src="../../content/css/images/icons/light/arrowLeft.png" alt="">
<span>Back</span>
</a>
<a class="tipN button greenB" original-title="Save Staff data" href="#" style="margin: 5px;" data-bind="click: SaveRestrictions, visible: showRestriction">
<img class="icon" src="../../content/css/images/icons/light/check.png" alt="">
<span>Save</span>
</a>
<a class="tipN button redB" original-title="Cancel all edits" data-bind="click: CancelRestriction, visible: showRestriction" style="margin: 5px;">
<div class="clear"> </div>
</div>
</div>
</div>
<div class="clear"> </div>
<div class="line"> </div>
<div>
</div>
<div id="footer">
<style>
<div id="leftsidehide" style="display: none;">
</div>
Upvotes: 1
Views: 934
Reputation: 14036
Try with following if it works for you:
//div[@class='middleNav']//a[@class='tipN button greenB']
Upvotes: 0
Reputation: 33
I'm not sure to fully understand your question. But here is what I would do from what understood :
//*[contains(@class, 'middleNav')][2]/*[contains(@class, 'tipN button greenB')]
Upvotes: 1
Reputation: 473833
Hope I understood you correctly:
(//div[@class="middleNav"])[2]/a[@class="tipN button greenB"]
Upvotes: 0