【发布时间】:2017-06-25 13:08:59
【问题描述】:
我正在使用 Python 上的 Selenium 在 WellGosh.com 上编写“添加到购物车”功能。
我的代码获得了正确的尺寸以添加到购物车并登录我的帐户并到达正确的送货地址,但是当我尝试确认送货方式(联邦快递)时,它不会让我点击继续按钮.
这是一个结帐代码示例:
def Checkout():
#brings you to your cart
driver.get('https://wellgosh.com/checkout/cart')
#clicks to checkout
checkout=driver.find_element_by_xpath('//*[@id="shopping-cart-table"]/tfoot/tr/td/div[2]/a')
checkout.click()
#Log in
login=driver.find_element_by_xpath('//*[@id="login-email"]')
login.send_keys(e_mail)
password=driver.find_element_by_xpath('//*[@id="login-password"]')
password.send_keys(Pass)
LogIn=driver.find_element_by_xpath('//*[@id="checkout-step-login"]/div/div[2]/div/button')
LogIn.click()
cont=driver.find_element_by_xpath('//*[@id="billing-buttons-container"]/button')
cont.click()
driver.implicitly_wait(100)
element = driver.find_element_by_xpath('//*[@id="shipping-method-buttons-container"]/button')
element.click()
我收到此错误:
selenium.common.exceptions.ElementNotVisibleException:消息:元素不可见
这是 HTML 代码的 sn-p:
</script>
</div>
<div class="buttons-set" id="shipping-method-buttons-container">
<p class="back-link"><a href="#" onclick="checkout.back(); return false;"><i class="fa fa-chevron-left plain"></i>Back</a></p>
<button type="button" class="button btn-continue" onclick="shippingMethod.save()">Continue</button>
<span id="shipping-method-please-wait" class="please-wait zoooooom" style="display:none;">
<i class="fa fa-cog fa-spin plain"></i>
</span>
</div>
</form>
【问题讨论】:
-
那么,如果继续按钮的父元素的 id 是“billing-buttons-container”,那么这个 ID 在你的 HTML sn-p 中的什么位置?