[英]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网站链接: 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.我可以检查服务条款框,但是当我尝试单击结帐按钮时,出现“没有这样的元素:无法定位元素:{“方法”:“css选择器”,“选择器”的错误:".btn btn--small-wide"}" 我试过 time.sleep 和 driver.implicitly_wait 但似乎都不起作用。 Any ideas?
有任何想法吗?
You can use the below css :您可以使用以下 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
You can try with the explicitWait
您可以尝试使用
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.