Код: Выделить всё
//separate class locator it lists down all elements
class AddToCartItem:
Inventory = "//div[@class='inventory_item']":
Product_Item_Button = "//button[text()='Add to cart']" #This locator contains x numbers of buttons
Код: Выделить всё
//class and methods to perform the job
class AddToCart(BasePage):
def select_item_to_add(self):
//iterate the buttons
for selectItem in self.get_elements(AddToCartItem.Product_Item_Button):
selectItem.click() //The selectItem.click() clicks all the button. how to handle the iteration of the elements in this section to click a random button from the x number of buttons instead of clicking them all.
Факт: Это нажимает все кнопки.
Я не знаю, как с этим справиться. Очень ценю вашу помощь.
Подробнее здесь: https://stackoverflow.com/questions/792 ... of-buttons
Мобильная версия