You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Selenium和Python点击网页中的Continue Checkout GIF元素?

Troubleshooting the "Continue Checkout" GIF Button Click Issue

Hey there, let's work through why you're having trouble clicking that Continue Checkout GIF button. Looking at your code and the HTML snippet you shared, here are targeted fixes to try:

1. Use the Element's Unique ID (Most Reliable)

The button has a unique id="formSubmit" attribute—this is the most stable way to locate it, way better than relying on the dynamic src value which might change. Replace your last line of code with this:

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "formSubmit"))).click()

2. Try a More Precise CSS Selector

If the ID approach doesn't work for some reason, use a CSS selector that combines multiple attributes of the button to narrow it down:

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.gaTrackedEvent[type='image'][value='Continue Checkout']"))).click()

3. Check for Overlays or Use Action Chains

Sometimes elements are hidden behind overlays, or the browser needs a little nudge to recognize the click. Try using ActionChains to move to the element first before clicking:

from selenium.webdriver.common.action_chains import ActionChains

button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "formSubmit")))
action = ActionChains(driver)
action.move_to_element(button).click().perform()

4. Clean Up Wait Conflicts

Quick side note: You're mixing explicit waits (WebDriverWait) and implicit waits (driver.implicitly_wait) in your code. This can cause unexpected timing issues. Stick to explicit waits throughout your script for consistency.

Also, your "Out of Stock" check has an invalid XPath—you probably meant something like:

element = WebDriverWait(driver, 1).until(EC.presence_of_element_located((By.XPATH, "//*[text()='Out of Stock!']")))

Give these fixes a shot, starting with the ID-based locator—it should resolve the click issue.

内容的提问来源于stack exchange,提问作者Stephen Brown

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 05:28:17