How to click on all the buttons that have the same name (one by one)

Hello
in the photo attache you can see 5 buttons with the same name and when u click on the button u get the window as it shows in the picture.
what i want to do is to let UiPath click on each one of them (one by one) and there is unknown number of theses buttons so its changeable.
So it will start clicking on the first button and then the second and so on until there are no buttons

your help will be very appreciated
thank you in advance

If it is in the table, you can click the button by row number (Go to Edit Selector Section). Use Ui Explorer to make the proper selector value.

1 Like

what do you mean by table, its a website and they have the same class but they are not in one table as i guess, can you give me an example

thanks

the only difference between the buttons is the itemid in html

I meant about if the web page has table tags. No problem, If you have the similar class values, use the idx property.

1 Like

so should i set the idx=‘class name’
like that:

but its not validated for me.
and should i use for each loop

Hi there @tamim1640

I would suggest an alternate safer method of clicking one by one if you do not need to verify its order (like first to last or last to first)

You can use the find children activity and ‘filter’ (<webctrl class='btn'/>) it according to the button class (use get descendants in the property panel of the find children and loop)

Once you get the elements in collection only the filtered IEnum. collection (UiPath.Core.UiElement) you can use click activity by passing the ‘item’ from the for each to the click activity - (ctype((item),uipath.core.uielement) and use it however you please.

1 Like

about the property panel i did the filter what about the scope and the ouput

thanks

image

Look at this for general idea in how to use find children activity:

1 Like

no im getting this
i took the class name from the html but its still wrong

image

Well,

You need to inspect the element and see what attribute it is and what tag it is. ‘class’ was just an example, it can just be a tag or something else too. Maybe you can paste the page source and the selector of the button then we can take a look. It is fairly easy. You can also check out the following link Search results for 'find children user:raghavendraprasad' - UiPath Community Forum for all find children answers where I have demonstrated the filtering and other aspects of looping through… -

1 Like

so i tried to set the tag also, but its not working
i am still new in uipath, here i attached the pictures, maybe you can check them

thanks

Hi, can you paste the whole page source expanding the button class only that you want to click?

thanks

do you mean this :slight_smile:

var storeFilters = ;
storeFilters.push({ title: “Carburant”, items: MPCatalog.getGasProducts(), allowMultipleSelection:false });
storeFilters.push({ title: “Filtrare după servicii”, items: MPCatalog.getServices(), allowMultipleSelection: true });
storeFilters.push({ title: “Filtrare după rețele”, items: MPCatalog.getGasNetworks(), allowMultipleSelection: true });
$event.register(“onBtnInfoClick”, BtnInfoClick);
$event.register(“onSelectedFilterChanged”, SelectedFuelChanged);

    $("#ctrlSearchToolbar").searchToolbarCtrl({ selectedOrderByOption: { id: 'dist', nume: 'KM' }, defaultSelectedOrderByOption: { id: 'dist', nume: 'KM' } });

    $("#ctrlStoreFilters").filterMenuCtrl({ title: 'Filtre:', filters: storeFilters, btnInfoTooltip: 'Detalii carburant', secondFilterClass: 'searchFilterId' });

    $event.register("onCurrentLocationEnabled", EnableCurrentLocation);
    $event.register("onSelectLocationEnabled", EnableSelectLocation);
    $event.register("onSelectedAreaChanged", ShowSelectedArea);
    $event.register("onGasNetworksFound", onGasNetworksFound);
    $event.register("onLocationFiltersChanged", LocationFiltersChanged);
    $event.register("onShowErrorDialog", onShowErrorDialog);
    $event.register("onGasFilterChanged", GasFilterChanged);

         $("#ctrlLocationFilters").filterLocationCtrl();


    $event.register("onBtnSearchClick", BtnSearchClick);
    $("#ctrlSearchToolbar").data("icsSearchToolbarCtrl").handleGasOrderByOptions([{ id: 'dist', nume: 'KM' }, { id: 'price', nume: 'RON' }], false);

    $event.register("onItemSelected", ResultListOnItemSelected);
    $("#ctrlResultList").resultListCtrl({
         listItemTemplate:
             '<div class="resultListItem" >'
             + '<div>'
             + '<img class="resultListItem-logo" src="#:logoRetea#">'
             + '</div>'
             + '<div class="resultListItem-content">'
             + '<div class="resultListItem-content-name">#:nume#</div>'
            + '<div class="resultListItem-content-details" style="color:rgb(120, 120, 120)">#:produs.nume#</div>'
             + '<div class="resultListItem-content-btns">'
             + '<div class="resultListItem-content-btn btnServicii" itemId="#:id#">Detalii</div>'
             + '<div class="resultListItem-content-btn btnRutare" itemId="#:id#" style="margin-left: 5px;">Navigare</div>'
             + '</div>'
             + '</div>'
             + '<div class="resultListItem-distance" style="width:100px;">'
             + '<div title="#:detaliiDistanta#">'
             + ' #:distantaAproximativa#'
             + '</div>'
             + '</div>'
             + '<div class="resultListItem-price">'
             + '<div>'
             + " #:(produs.pret != null ? produs.pret : '-')#"
             + '</div>'
             + '</div>'
            + '</div>',
        emptyMessage: 'Vă rugăm să selectați produsul și modalitatea de căutare'
    });

    $(document).on('click', ".btnServicii", function (e) {
             e.preventDefault = true;
             if (this.attributes.itemId != null && this.attributes.itemId.value != null) {
                 var dataItem = $("#ctrlResultList").data("icsResultListCtrl").getDataItemById(this.attributes.itemId.value);
                 $("#productListCtrl").data("icsFuelAndServicesListManagerCtrl").closeAll();
                 $("#productListCtrl").data("icsFuelAndServicesListManagerCtrl").showWindow(dataItem.id);
             }
         });

    $(document).on('click', ".btnRutare", function (e) {
             e.preventDefault = true;
             if (this.attributes.itemId != null && this.attributes.itemId.value != null) {

                 var dataItem = $("#ctrlResultList").data("icsResultListCtrl").getDataItemById(this.attributes.itemId.value);
                 window.open("https://www.google.com/maps/dir"
                     + '/' + startPointCoord_Lat.toString() + ',' + startPointCoord_Lon.toString()
                     + '/' + dataItem.coords.Lat.toString() + ',' + dataItem.coords.Lon.toString(), '_blank');
             }
         });

The above is the page source…

Can you try "<webctrl aaname='Detailii'>" ?

Or

"<webctrl text='Detailii'>"

also, it can either be innertext, hetmlinnertext, or soemthing else also, you will come to know during thorough inspect element.

1 Like

Hi @tamim1640,

Another Simple way,
<webctrl aaname='Detailii' idx='1'> for first button
<webctrl aaname='Detailii' idx='2'> for second button
<webctrl aaname='Detailii' idx='3'> for third button
.
.
.
<webctrl aaname='Detailii' idx='n'> for nth button

But please ensure you the element exist before clicking the button

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.