Once I add the following item to cart: http://www.supremenewyork.com/shop/accessories/wau85w4km/cxv3ybp1w and go to the check out page: https://www.supremenewyork.com/checkout, there is a terms and conditions checkbox that I’m attempting to check off with Browser’s splinter
but I’m not able to do so:
e.g. Tried the following but all encountered an error:
from splinter import Browser
browser = Browser("chrome")
browser.find_by_id('order_terms').click()
#Error: selenium.common.exceptions.WebDriverException: Message: unknown error
browser.check('order[terms]').click()
#Error: selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
browser.find_by_name('order[terms]').click()
#Error: selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
What could I be doing wrong? And how can I go about checking the checkbox with the Browser splinter
?
Thank you in advance and will be sure to upvote/accept answer
Two major things to point out:
label
element containing the input
and other auxiliary elementsHere is the complete code:
from splinter import Browser
browser = Browser("chrome")
browser.visit("http://www.supremenewyork.com/shop/accessories/wau85w4km/cxv3ybp1w")
browser.wait_time = 10
try:
browser.is_element_visible_by_css("input[name=commit]", 10)
browser.find_by_css("input[name=commit]").first.click()
browser.is_element_visible_by_css("a.checkout", 10)
browser.find_by_css("a.checkout").first.click()
browser.is_element_present_by_css("label.terms", 10)
browser.find_by_css('label.terms').click()
finally:
browser.quit()
Here is a working code that goes to the main page, navigates to the third product in the scroller, adds it to cart, checks out and accepts the terms of use, time.sleep()
at the end is just for you to see the result:
from splinter import Browser
browser = Browser("chrome")
browser.visit("http://www.supremenewyork.com/shop")
browser.wait_time = 10
try:
# open a product
browser.is_element_visible_by_css("#shop-scroller > li > a", 10)
browser.find_by_css("#shop-scroller > li > a")[2].click()
# add to cart
browser.is_element_visible_by_css("input[name=commit]", 10)
browser.find_by_css("input[name=commit]").first.click()
# checkout
browser.is_element_visible_by_css("a.checkout", 10)
browser.find_by_css("a.checkout").first.click()
# accept terms and conditions
browser.is_element_present_by_css("label.terms", 10)
browser.find_by_css('label.terms').click()
import time
time.sleep(10)
finally:
browser.quit()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With