【发布时间】:2021-04-19 05:08:52
【问题描述】:
我是编码新手,我正在尝试创建一个结帐机器人。我正在使用硒来帮助我做到这一点。到目前为止,我的代码一直有效,直到结帐我似乎无法让我的机器人点击结帐按钮。
这是我检查结帐按钮时得到的结果。
<a href="https://www.bestbuy.ca/identity/global/signin?redirectUrl=https%3A%2F%2Fwww.bestbuy.ca%2Fcheckout%2F%3Fqit%3D1%23%2Fen-ca%2Fshipping%2FON%2FM4W&lang=en-CA&contextId=checkout" class="button_E6SE9 primary_1oCqK continueToCheckout_3Dgpe regular_1jnnf" data-automation="continue-to-checkout"> == $0
我试过了
find_element_by_class_name("continueToCheckout_3Dgpe")
find_element_by_xpath( '//*[@class="continueToCheckout_3Dgpe"]' ).click()
findElement(By.cssSelector("a[href*='https://www.bestbuy.ca/identity/global/signin?redirectUrl=https%3A%2F%2Fwww.bestbuy.ca%2Fcheckout%2F%3Fqit%3D1%23%2Fen-ca%2Fshipping%2FON%2FM4W&lang=en-CA&contextId=checkout']")).click();
find_element_by_partial_link_text('https://www.bestbuy.ca/identity/global/signin?redirectUrl=https%3A%2F%2Fwww.bestbuy.ca%2Fcheckout%2F%3Fqit%3D1%23%2Fen-ca%2Fshipping%2FON%2FM4W&lang=en-CA&contextId=checkout')
find_element_by_xpath('//a[@href="https://www.bestbuy.ca/identity/global/signin?redirectUrl=https%3A%2F%2Fwww.bestbuy.ca%2Fcheckout%2F%3Fqit%3D1%23%2Fen-ca%2Fshipping%2FON%2FM4W&lang=en-CA&contextId=checkout"]')
find_element(By.xpath("//a[@href='https://www.bestbuy.ca/identity/global/signin?redirectUrl=https%3A%2F%2Fwww.bestbuy.ca%2Fcheckout%2F%3Fqit%3D1%23%2Fen-ca%2Fshipping%2FON%2FM4W&lang=en-CA&contextId=checkout']"))
似乎没有任何效果,也没有点击结帐按钮。如果对如何解决此问题有任何想法,那将很有帮助!谢谢你:)
【问题讨论】:
-
您遇到错误了吗?
-
@BuddyBobIII 我假设是这样。我有一个while循环,如果结帐失败,它将重新启动程序,这就是我每次结帐时发生的事情。我在同一页面上尝试了其他按钮,例如 Paypal 和 Visa Checkout,它们都可以正常点击。
标签: python selenium findelement best-buy-api