I am trying to create a checkout bot for myself. The only problem with my code is that it can't detect when the add to cart button is enabled or disabled.
This is the input I get when the button is disabled:
<button disabled="" class="button_E6SE9 primary_1oCqK addToCartButton_1op0t addToCartButton regular_1jnnf disabled_mu48L" type="submit"><span class="content_3Dbgg" tabindex="-1"><div class="addToCartLabel_YZaVX"><span>Add to Cart</span></div></span></button>
And this is the input I get when the button is enabled:
<button class="button_E6SE9 primary_1oCqK addToCartButton_1op0t addToCartButton regular_1jnnf" type="submit"><span class="content_3Dbgg" tabindex="-1"><div class="addToCartLabel_YZaVX"><span>Add to Cart</span></div></span></button>
This is what I have going on to get it to detect the buttons however it only works when the button is enabled.
while not buyButton:
try:
addToCartBtn = addButton = browser.find_element_by_class_name("addToCartButton")
addToCartBtn.click()
print("Item in stock")
except:
addToCartBtn = addButton = browser.find_element_by_class_name("disabled_mu48L")
browser.refresh()
print("Item out of stock")
continue
I have tried using XPATH and also using the different class names to see if it can work but nothing seems to work. Any suggestions or hints would be helpful thank you!!