2

I was running a selenium file and I keep getting this error, I know what line the error is on but I think the only reason it is there is because it keeps looping on that line until a button is clickable. But the rest of it I do not know what it means. Any ideas on what this means?

[9708:37344:1229/082641.495:ERROR:chrome_browser_main_extra_parts_metrics.cc(226)] crbug.com/1216328: Checking Bluetooth availability started. Please
[9708:37344:1229/082641.495:ERROR:chrome_browser_main_extra_parts_metrics.cc(229)] crbug.com/1216328: Checking Bluetooth availability ended.
[9708:37344:1229/082641.496:ERROR:chrome_browser_main_extra_parts_metrics.cc(232)] crbug.com/1216328: Checking default browser status started. Please
[9708:7028:1229/082641.499:ERROR:device_event_log_impl.cc(214)] [08:26:41.499] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node
[9708:37344:1229/082641.533:ERROR:chrome_browser_main_extra_parts_metrics.cc(236)] crbug.com/1216328: Checking default browser status ended.
[4132:5052:1229/092045.310:ERROR:ssl_client_socket_impl.cc(983)] handshake failed; returned -1, SSL error code 1, net_error -101
[4132:5052:1229/092045.311:ERROR:ssl_client_socket_impl.cc(983)] handshake failed; returned -1, SSL error code 1, net_error -101
Traceback (most recent call last):
  File "C:\Users\rhino\BotArmy\gpubuyer2.py", line 3, in <module>
    buyer("URL")
  File "C:\Users\rhino\BotArmy\Functions.py", line 85, in buyer
    CheckBuyButton()

code where is happening: specifically on the addToCartBtn line

   while not check:    
            if(wd.find_element(By.CLASS_NAME,"add-to-cart-button").is_enabled()):
                addToCartBtn = wd.find_element(By.CLASS_NAME, "add-to-cart-button")
                check = True
            else:
                wd.refresh()        

html of element

<button class="c-button c-button-primary c-button-lg c-button-block c-button-icon c-button-icon-leading add-to-cart-button" type="button" data-sku-id="6419203" data-button-state="ADD_TO_CART" style="padding:0 8px"><svg aria-hidden="true" role="img" viewBox="0 0 100 100" style="width:16px;height:16px;margin-right:9px;fill:currentColor"> Add to Cart</button>
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

To click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.c-button.c-button-primary.c-button-lg.c-button-block.c-button-icon.c-button-icon-leading.add-to-cart-button[data-button-state='ADD_TO_CART']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='c-button c-button-primary c-button-lg c-button-block c-button-icon c-button-icon-leading add-to-cart-button' and @data-button-state='ADD_TO_CART']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352