-
Notifications
You must be signed in to change notification settings - Fork 1
/
release_catch.py
120 lines (78 loc) · 3.69 KB
/
release_catch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from config import *
import time
def checkout():
driver = webdriver.Chrome("chromedriver.exe")
print("Moving to Cart..")
link = "https://www.adidas.co.in/cart"
driver.get(link)
time.sleep(3)
print("Checking Out..")
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[2]/div[1]/div/div[3]/div/button/span").click()
checkout_pay(driver)
def checkout_pay(driver=None):
time.sleep(7)
print("-Scrolling to Bottom")
SCROLL_PAUSE_TIME = 0.5
last_height = driver.execute_script("return document.body.scrollHeight")
while True:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(SCROLL_PAUSE_TIME)
new_height = driver.execute_script("return document.body.scrollHeight")
if new_height == last_height:
break
last_height = new_height
print("-Agree to Terms")
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/main/div[6]/div[1]/div/div/label/input").click()
print("-Proceeding")
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/main/div[7]/button").click()
time.sleep(5)
print("-Payment")
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Cash on Delivery']"))).click()
print("-Cash On Delivery")
time.sleep(1)
# Remove the below comment to proceed placing an order | Disabled for safety purpose
#wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Place Order']"))).click()
print("-Placing Order")
print("\nDone")
def site_login():
print("CheckOut Test-")
driver = webdriver.Chrome("chromedriver.exe")
driver.get(bagout_link)
#driver.get(early_product_lnk)
print("-Running Pre Bagout")
print("Just a Sec..")
try:
fsize = "//span[text()='" + str(size) + "']"
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, fsize))).click()
except Exception as e:
print(e)
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Add To Bag']"))).click()
time.sleep(5)
print("-Moving to Cart")
#link = "https://www.adidas.co.in/cart"
#driver.get(link)
time.sleep(3)
print("-Checking Out")
#wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Checkout']"))).click()
driver.find_element_by_xpath('//*[@id="modal-root"]/div/div/div/div[2]/div/section/div[3]/a[2]/span').click()
print("-Filling In Login Details")
username = wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[1]/div/div/form/div[2]/div/div[1]/input")))
print("-Entering Email")
username.clear()
username.send_keys(email)
pas = driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[1]/div/div/form/div[3]/div[2]/div[1]/input")
print("-Entering Password")
pas.clear()
pas.send_keys(password)
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[1]/div/div/form/div[7]/button/span"))).click()
print("-Logging In")
time.sleep(5)
print("\n\n YESSSSSS !!!!!!!!!!!!!! \n\n")
print("-Delivery Info From Account")
checkout_pay(driver)
site_login()