As you can see in the selector, automationid attribute holds the name of the button. You need to create dynamic selector by passing variable into automationid attribute value.
Have a look below thread to know about passing variable into the selector.