-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtarget_bot.py
More file actions
32 lines (28 loc) · 1.28 KB
/
target_bot.py
File metadata and controls
32 lines (28 loc) · 1.28 KB
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
from selenium import webdriver
from time import sleep
class target_bot():
def __init__(self,website,username,password):
self.site = website
self.username = username
self.password = password
self.driver = webdriver.Chrome('/Users/Sam/Downloads/chromedriver')
def login(self):
self.driver.implicitly_wait(30)
email_in = self.driver.find_element_by_xpath('//*[@id="username"]')
email_in.send_keys(self.username)
password_in = self.driver.find_element_by_xpath('//*[@id="password"]')
password_in.send_keys(self.password)
login_button = self.driver.find_element_by_xpath('//*[@id="login"]')
login_button.click()
self.driver.implicitly_wait(30)
def get_item(self):
self.driver.get(self.site)
self.driver.implicitly_wait(30)
buy = self.driver.find_element_by_xpath('//*[@id="viewport"]/div[5]/div/div[2]/div[3]/div[1]/div/div[3]/div[1]/div[2]/button')
buy.click()
self.driver.implicitly_wait(30)
def checkout(self):
self.driver.get('https://www.target.com/co-cart')
move_to_login = self.driver.find_element_by_xpath('//*[@id="orderSummaryWrapperDiv"]/div/div/div[2]/button')
move_to_login.click()
self.driver.implicitly_wait(30)