Ksuby
Ksuby

Reputation: 73

Python Selenium , Click a checkbox

I am trying to create an add to car bot which finds the item and selects the size and fills out the user billing and card information. I am currently stuck on the checkboxes of the site. I've tried to use the XPath of the checkbox and it gives me an error or it won't execute.

The website I am using is as below:

https://www.supremenewyork.com/checkout

Below is a picture of the checkout page with the checkbox enter image description here

Here is the html elements used for the code enter image description here

Below is my code that I used to get the program to find the checkbox element and use a .click() to select the box.

Checkboxes = browser.find_element_by_xpath('//*[@id="cart-cc"]/fieldset/p[2]/label/')
Terms = ActionChains(browser).move_to_element(Checkboxes).click()
Terms.perform()

Upvotes: 1

Views: 4282

Answers (1)

Deepak Kumar
Deepak Kumar

Reputation: 99

use below code:

Webelement element = browser.find_element_by_xpath('//label[./div[@class="icheckbox_minimal"]/input[type="checkbox"]]/div/input');
element.click();

Upvotes: 1

Related Questions