How to find next element of same selector?

Hi,
I want to click a div element and then I want to find if next div with same selector is exists. If exists then click the next div and so on. At last when the next div with same selector is not exists then it will be finished.

screenshot-www.facebook.com-2021.01.04-16_27_42

Hi @awaisji2001,
I’m not sure if Messenger is the easy to automate example as Facebook is protecting data by encrypting each element. Can you provide two examples of selectors so we could see if there is something what can be grabbed?

Hi Sir @Pablito,
I’m very sorry for replying late. I show you two examples of selectors.

First selector
<webctrl src='https://www.facebook.com/umarismailkrk/inbox?cquick=jsc_c_k&amp;cqui*' tag='IFRAME' /> <webctrl aria-role='presentation' idx='1' tag='DIV' />
Second selector
<webctrl src='https://www.facebook.com/umarismailkrk/inbox?cquick=jsc_c_h&amp;cqui*' tag='IFRAME' /> <webctrl aria-role='presentation' idx='2' tag='DIV' />

As you see in your examples the IDX parameter is only one which changes. I think you can base on that. The simplest way which comes to my mind is that you can build int32 variable working as a counter (which will be used in selector for idx parameter) from 1 to X and then place everything in the loop which will click mentioned selector and then add +1 to the counter. Finally this could be placed in try-catch activity so when all numbers will be used and you reach number out of scope you will just end the process.

Sir, I try this but when scrolling occurs the new loaded elements rearrange by IDX 1 to so on then again scrolling occurs the new loaded elements rearrange by IDX 1 to so on.

What if you will use send hotkey for down arrow to move to next position instead of clicking it?

Sir, I use pgdown in hotkey.

If you will use send hotkey for down arrow to move to next position instead of clicking it then it click only first 7 elements.

You can put send hotkey into the loop where you can define your own counter for how many times it should go. And this can be put additionally to try-catch to stop when you will go out of the limit.

OK Sir thanks, I try this.