Looping multiple buttons in dynamic webpage


Hi all,
Can anybody help me for this?
How to loop buttons in webpage where we are not sure how many buttons will come like if i saw today it is 5 button but may be tomorrow it will be 10 buttons…How to loop through all the buttons dynamically?
sharad kumar

How to Iterate nested div element using selenium script


Hi ,
My requirement is related to Dynamic Web page…There i want to loop through buttons like today i have 5 buttons may be based on execution tomorrow it may have more or less button…How to handle this dynamic nature of execution
Sharad Kumar



Here is an example to click through each button on the bootstrap Buttons

recording archive: dynamic-web-page.7z (1.4 KB)

The idea is to:

  • get a list of all buttons using 1 XPATH - https://getbootstrap.com/docs/4.0/components/buttons/
  • for each list element:
    – click on a button by dynamic XPATH - //div[@class='bd-example'][1]/button[${iterator}]
    – increase the ${iterator} variable by 1

As a result, robot will click through all buttons one by one using the following XPATHs: