-1

I cant add an item to the cart because the button is not being selected.

the button in question is the "ADD TO CART" and its only classification is its class called "btn_primary btn_inventory".

this button should add the item selected to the cart as shown:

here is the non working code i used to get it to select a random button and to click on it:

WebElement areaInventory = navegador.findElement(By.id("inventory_container"));
        List<WebElement> l1 = areaInventory.findElements(By.className("btn_primary btn_inventory"));
        for(int i=0;i< l1.size();i++){
            Random r = new Random();
            l1.get(r.nextInt(6)).click();
        }
Chel0
  • 1

1 Answers1

0

Try doing the below mentioned change.

Change List<WebElement> l1 = areaInventory.findElements(By.className("btn_primary btn_inventory"));

to List<WebElement> l1 = areaInventory.findElements(By.cssSelector(".btn_primary.btn_inventory"));

Dharman
  • 30,962
  • 25
  • 85
  • 135