Skip to content
Advertisement

Unable to locate element Selenium:

    tos = driver.find_element_by_id("TOS_CHECKBOX").click()
    check_out = driver.find_element_by_class_name("btn btn--small-wide")
    check_out.click()

Link to website: https://www.squidindustries.co/cart

I’m able to check the terms of service box but then when I try to click the checkout button I am given an error of “no such element: Unable to locate element: {“method”:”css selector”,”selector”:”.btn btn–small-wide”}” I’ve tried time.sleep and driver.implicitly_wait but neither seem to work. Any ideas?

Advertisement

Answer

You can use the below css :

input[value='Check out']

in code :

check_out = driver.find_element_by_css_selector("input[value='Check out']")
check_out.click()

or

With Explicit waits :

checkout = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"input[value='Check out']")))
checkout.click()

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement