Reputation: 25
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?
Upvotes: 0
Views: 104
Reputation: 29362
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
Upvotes: 1
Reputation: 1352
You can try with the explicitWait
checkbox=WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//input[@id='TOS_CHECKBOX' and @type='checkbox']")))
checkbox.click()
checkout = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//input[@type='button' and @class='btn btn--small-wide']")))
checkout.click()
import
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
Upvotes: 0