samedi 7 décembre 2019

How to select a particular element from the list based on users input

I have an element that is a list and I want to click on it based on users input: Ex: Number 1: clicks first element: Number 2 clicks second element. Number 3 clicks third element. Would switch method work better?

public void selectList(Integer number) {
     if(number == 1){
          elementList.get(0).click()
     }
      else if (number == 2) {
           elementList.get(1).click() 
     }
     else if(number == 3) {
           elementList.get(2).click()
      }
       else if(number == 4) {
           elementList.get(3).click()
      }

Aucun commentaire:

Enregistrer un commentaire