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?
Thanks
sharad kumar

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
Thanks
Sharad Kumar

@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:

//div[@class='bd-example'][1]/button[1]
//div[@class='bd-example'][1]/button[2]
//div[@class='bd-example'][1]/button[3]
//div[@class='bd-example'][1]/button[4]
//div[@class='bd-example'][1]/button[5]
//div[@class='bd-example'][1]/button[6]
//div[@class='bd-example'][1]/button[7]
//div[@class='bd-example'][1]/button[8]
//div[@class='bd-example'][1]/button[9]
1 Like

Hi

Is there a way to get the number of button in the dynamic webpage

The way i am proceeding, i am making use of the xpath to get multiple value which i save it in a list variable after that i get the size of the of list , later in the recording i had the intention to use the expression in this post and use of For Each and IF condition to click on each one every-time but recording keep on failing at the xpath itself

Please advice

@h01234567 your approach is correct - you need to save the elements in a list, calculate their number and then use indexes to click each of them - https://kb.workfusion.com/display/RPAe/XPath+Guide#XPathGuide-ListsofElements

With what error does the action fail? Maybe, there is a mistake in the XPath?

I have increase the wait maybe the web page was not correctly loading

Did increasing the Wait time help to solve the issue?

Yes I do not know why the xpath was not working previously

1 Like