0

How to identify this button in C#:

 <button class="reward_link_redeem_button_style" onclick="RedeemRPProduct('free_points_1')">REDEEM</button>
 <button class="reward_link_redeem_button_style " onclick="RedeemRPProduct('free_points_50')">REDEEM</button>

But there are like 4 buttons called equal, and to differentiate them you need the ('free_points_1') as well as ('free_points_10'), etc.

1 Answer 1

0
  1. Using CSS selector

    .reward_link_redeem_button_style
    

    OR

    button[class='reward_link_redeem_button_style']
    
  2. Using xpath

    //button[contains(.,'REDEEM')]
    

    OR

    //button[contains(@onclick,'RedeemRPProduct')]
    

Update

As per recent update content. You can locate the element using onclick attribute as it make the element unique. Use below xpath :

//button[contains(@onclick,'free_points_50')]
5
  • But there are like 4 buttons called equal, and to differentiate them you need the ('free_points_1') as well as ('free_points_10'), etc. Commented Oct 6, 2018 at 16:49
  • Can you update the question with some more HTML code so I can help you out
    – NarendraR
    Commented Oct 6, 2018 at 16:50
  • Try this //button[contains(@onclick,'free_points_50')] make sure you have passed correct number
    – NarendraR
    Commented Oct 6, 2018 at 18:49
  • @GabrielLugo, I have updated the answer as per your update.If this answer is helpful for you then please accept so it can be helpful for other. Have some other queries then please post. thanks
    – NarendraR
    Commented Oct 9, 2018 at 7:15
  • You can still use CSS instead of xpath: "button[onclick='RedeemRPProduct('free_points_50')']"
    – Moro
    Commented May 8, 2019 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.