-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroup_booking.py
More file actions
107 lines (85 loc) · 3.9 KB
/
Copy pathgroup_booking.py
File metadata and controls
107 lines (85 loc) · 3.9 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
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
from config import *
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
import time
options = Options()
options.add_argument("--dns-prefetch-disable")
options.add_argument("--disable-features=NetworkService")
options.add_argument("--disable-features=NetworkServiceInProcess")
options.add_argument('--auto-select-certificate-for-urls=https://app.mapiq.com/')
options.add_argument('--disable-popup-blocking')
driver = webdriver.Chrome(
service=Service(ChromeDriverManager().install()),
options=options
)
url = 'https://app.mapiq.com/'
driver.get(url)
actions = ActionChains(driver)
main_window_handle = driver.current_window_handle
try:
print('Logging in...')
login_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CLASS_NAME, 'sc-fbYMXx.dyuplY'))
)
actions.click(login_button).perform()
email_input = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.ID, 'signInName'))
)
email_input.clear()
email_input.send_keys(EMAIL + Keys.ENTER) #TODO: remove email address
password_input = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CLASS_NAME, 'form-control.input.ext-input.text-box.ext-text-box'))
)
password_input.clear()
password_input.send_keys(PASSWORD + Keys.ENTER) #TODO: remove password
time.sleep(10)
calendar_tab = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'a[data-testid="organisms-navigation-calendar"]'))
)
actions.click(calendar_tab).perform()
print('Logged in successfully.')
date_card = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, f'a[data-testid="undefined-card-cell-{DATE}"]'))
)
actions.click(date_card).perform()
where_will_you_be_tile = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[data-testid="workday-tile"]'))
)
actions.click(where_will_you_be_tile).perform()
singapore_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div[2]/div/div/div[3]/div'))
)
actions.click(singapore_button).perform()
invitees_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.sc-bqWxrE.sc-gsGlKL.fHjzj.eRpPDZ'))
)
actions.click(invitees_button).perform()
for invitee in INVITEES:
emails_textarea = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'textarea[data-testid="molecules-ChipSelect_text-input"]'))
)
actions.click(emails_textarea).send_keys(invitee.email).perform()
invitee_cell = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'p[data-testid="molecules-InviteeCardCell_name-or-email"]'))
)
actions.click(invitee_cell).perform()
confirm_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div[3]/div/div[3]/button'))
)
actions.click(confirm_button).perform()
workspace_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[data-testid="select-workspace-button"]'))
)
actions.click(workspace_button).perform()
except Exception as e:
print('An error occurred:', e)
finally:
input("Press Enter to close the browser and end the script...")
driver.quit()