Browse Source

Adding cprlab script

main
kusum 6 months ago
parent
commit
9ee6e18b62
1 changed files with 51 additions and 0 deletions
  1. 51
    0
      GSAutomation/scripts/cpr_labscript.py

+ 51
- 0
GSAutomation/scripts/cpr_labscript.py View File

@@ -0,0 +1,51 @@
#!/usr/bin/env python3

import time
from selenium import webdriver
from selenium.webdriver.common.by import By

def search_for_dress(driver, user_id):
driver.maximize_window()
url = f'https://{user_id}.cpr-akashop.com/'
driver.get(url)
time.sleep(1)
# Find and click on the magnifying glass icon
magnifying_glass = driver.find_element(By.CSS_SELECTOR, '#header-grid > nav.header--row.header-main.hide-on-mobile.hide-on-tablet.layout-full-contained.nv-navbar.header--row > div > div > div > div.hfg-slot.right > div > div.item--inner.builder-item--header_search_responsive > div > div > a > svg')
magnifying_glass.click()
time.sleep(1)
# Find the search box and search for "dress"
search_box = driver.find_element(By.CSS_SELECTOR, '#header-grid > nav.header--row.header-main.hide-on-mobile.hide-on-tablet.layout-full-contained.nv-navbar.header--row > div > div > div > div.hfg-slot.right > div > div.item--inner.builder-item--header_search_responsive > div > div > div > div.form-wrap > form > input')
search_box.send_keys('dress')
search_box.submit()
time.sleep(3)
# Find and click on the Striped Dress search result
striped_dress_link = driver.find_element(By.CSS_SELECTOR, '#post-82 > div > div > div > div.non-grid-content.alternative-layout-content > h2 > a')
striped_dress_link.click()
time.sleep(3)
# Add the Striped Dress to the cart
add_to_cart_button = driver.find_element(By.CSS_SELECTOR, '#product-82 > div.nv-single-product-top > div.summary.entry-summary > form > button')
add_to_cart_button.click()
time.sleep(3)
# Click on View Cart
view_cart_button = driver.find_element(By.CSS_SELECTOR, '#content > div > div > div > div.woocommerce-notices-wrapper > div > a')
view_cart_button.click()
time.sleep(3)
# Click on Proceed to Checkout
proceed_to_checkout_button = driver.find_element(By.CSS_SELECTOR, '#content > div > div > div > div.nv-content-wrap.entry-content > div > div.cart-collaterals > div > div > a')
proceed_to_checkout_button.click()
time.sleep(3)
driver.quit()

if __name__ == "__main__":
user_id = input("Please enter your user ID: ")
# Chrome
driver = webdriver.Chrome()
search_for_dress(driver, user_id)

Loading…
Cancel
Save