Volatil3
Volatil3

Reputation: 14978

How to same element with unique XPath/CSS selector by both ID and Class?

I have the following HTML:

<div id="btnCreditCard" class="paymentBtn bitcoin" style="display: none">
    <a class="button button-primary button-override has-icon-right" href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(8);">
        <i class="button-icon-left"></i>Continue To Order Review<i class="button-icon-right fa fa-caret-right"></i>
    </a>
</div>

<div id="btnMasterPass" class="paymentBtn masterpass" style="display: none;">
    <a href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(4);" title="MasterPass" style="cursor: pointer;">
        <img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mcpp_wllt_btn_chk_147x034px.png" alt="MasterPass" />
    </a>
</div>

<div id="btnCreditCard" class="paymentBtn npa" style="display: none">
    <a class="button button-primary button-override has-icon-right" href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(5);">
        <i class="button-icon-left"></i>Continue To Order Review<i class="button-icon-right fa fa-caret-right"></i>
    </a>
</div>

<div id="btnCreditCard" class="paymentBtn billlater" style="display: none">
    <a class="button button-primary button-override has-icon-right" href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(6);">
        <i class="button-icon-left"></i>Continue To Order Review<i class="button-icon-right fa fa-caret-right"></i>
    </a>
</div>

I have to pick Anchor having parent DIV <div id="btnCreditCard" class="paymentBtn billlater" style="display: none">. The xPath I am currently using is ('//*[@id="btnCreditCard"]/a')

Upvotes: 0

Views: 613

Answers (1)

unutbu
unutbu

Reputation: 879361

You could use and in the XPath:

'//*[@id="btnCreditCard" and @class="paymentBtn billlater"]/a'

Upvotes: 3

Related Questions