Chrome Webdriver 无法完成产品结帐自动化 [英] Chrome Webdriver unable to complete product checkout automation
问题描述
我正在尝试自动结帐
我使用了显式等待来等待动态内容加载(即 HTML 现在与完全加载页面的预期 HTML 匹配(即
<button type="submit" title="Place Order" class="button btn-checkout" onclick="review.save();"><span><span>Place Order<;/span></span></button>
现已存在,但仍在无限期加载.我不确定要等待哪些其他元素.
如果您在上述网站上遇到订单问题,请确保在您使用相同的详细信息手动结账时,该网站没有不同的行为.
虽然我在同一个站点上尝试过访客用户结账,但我在下面的 API 中遇到了连接超时错误
<块引用>POST https://www.converse.ca/braintree/checkout/quoteTotal/net::ERR_CONNECTION_TIMED_OUT
导致旋转器继续滚动.
如果存在特定于元素的问题,那么您可以处理.下单的最佳用例是
当它位于 Order Review
部分时,无论位置或按钮是否准备就绪,您都必须使用明确的等待条件.参考下面的代码
from selenium.webdriver.support.ui import WebDriverWait从 selenium.webdriver.support 导入 expected_conditions 作为 ECWebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button[title='Place Order']")).click()
然后等到 Spinner 消失以确保订单已完成.
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "review-please-wait"))
注意:请确保每个部分的等待时间都足够,直到信息被加载,因为在您选择某个选项时会有一些 API 调用.所以它会导致你的脚本失败,因为你的脚本很好,但系统还没有准备好.
I am attempting to automate the checkout of a product on this website. However, at the very last step when a button is supposed to be clicked to submit the payment, the button just loads and the payment is neither completed nor declined (Pop up expected to tell the user that it has been declined).
As you can see below by the picture, the order information just keeps "loading" or "spinning" indefinitely.
I am not sure why this is happening. Any help would be appreciated.
Edit: I've used an explicit wait to wait for the dynamic content to load (i.e. HTML now matches the expected HTML of fully loaded page (i.e.
<button type="submit" title="Place Order" class="button btn-checkout" onclick="review.save();"><span><span>Place Order</span></span></button>
now exists, but it is still loading indefinitely. I'm not sure which other elements to wait for.
If you are facing problem with the order on the mentioned site then please make sure that site do not have different behavior while you do checkout with the same details, manually.
While i have tried guest user checkout on same site i have faced connection timeout error in below API
POST https://www.converse.ca/braintree/checkout/quoteTotal/ net::ERR_CONNECTION_TIMED_OUT
Which causing that spinner continue rolling.
If there is element specific issue then you can handle that. Best usecase for the placing order are
While it lands on Order Review
section you have to use explicit wait condition whether place or button is ready. refer below code
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button[title='Place Order']")).click()
And then wait until spinner goes away to make sure order has been completed.
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "review-please-wait"))
NOTE : Make sure your waiting time is sufficient for each section until info get loaded because there are some API call at the time you select some option. So it can cause your script failure because your script is fine but system is not ready.
这篇关于Chrome Webdriver 无法完成产品结帐自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!