How to automate the buttons with same class and actions in selenium webdriver?

e.x  sintaxs first button is:
<button class=”btn bid-hotel-btn” type=”button” onclick=”buyNow(0,false)”>Beli Sekarang</button>
and the second button is:<button class=”btn bid-hotel-btn” type=”button” onclick=”buyNow(1,false)”>Beli Sekarang</button>

the difference is only the onlick event on HTML. and I want automatically click one button everytime I automate the website. Thanks

Default Asked on July 18, 2016 in Selenium WebDriver.
Add Comment
  • 2 Answer(s)

    Hi Fhrara,

    First try to get the parent element for the same and then try acting on the child element. For ex;

     

    Please correct the syntax, if it is wrong.

    Regards,
    Lakshay Sharma

    Professor Answered on July 19, 2016.
    Add Comment

    These two should work..

    Train Answered on July 25, 2016.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.