Q:

How to select an element when either of the elements can be found using Selenium and Java

the quantity button design is different on each load. i have identified them
but i want to proceed when either one element is found.
//select quantity 2
//sometimes button A appear
driver.findElement(By.xpath("//select[@id='quantity']")).click();
Select quantity = new Select(driver.findElement(By.xpath("//select[@id='quantity']")));
quantity.selectByIndex(1); 

//sometimes button B appear
driver.findElement(By.xpath("//select[@id='amt']")).click();
Select amt = new Select(driver.findElement(By.xpath("//select[@id='amt']")));
quantity.selectByIndex(1); 

A:

You can use findElements() instead of findElement(), that would return a list of web element.
Now, if the size is 1, your script will get to know that particular element is present. If the size id 0, then button will not be visible in UI.  
Something like this for quantity button :  
List<WebElement> quantityButton = driver.findElements(By.xpath("//select[@id='quantity']"));
if(quantityButton.size()==1){
   quantityButton.get(0).click();
}  

For amt Button : 
List<WebElement> amtButton = driver.findElements(By.xpath("//select[@id='amt']"));
    if(amtButton.size()==1){
       amtButton.get(0).click();
    }  

You can write respective else block as per your requirement.
Different approach would be to go with try-catch block.  
Let me know if that helps.

