-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabrarvan.py
154 lines (123 loc) · 5.83 KB
/
abrarvan.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import os
import time
from getpass import getpass
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def login_to_abrarvan():
driver = webdriver.Chrome()
driver.get("https://accounts.arvancloud.ir/login?lang=fa")
email = os.environ.get('ARVAN_EMAIL')
password = os.environ.get('ARVAN_PASSWORD')
if not email:
email = input('Enter your email: ')
if not password:
password = getpass('Enter your password: ')
email_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, 'body > div > div.l-withBanner__row > div.l-withBanner__content > div > div:nth-child(1) > div > form > div.relative.v1\:ar-textField.p-login__input.p-login__input--email > input'))
)
email_input.send_keys(email)
password_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '/html/body/div/div[2]/div[1]/div/div[1]/div/form/div[2]/div/input'))
)
password_input.send_keys(password)
signin_submit_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.ID, 'login-submit'))
)
signin_submit_button.click()
time.sleep(30)
return driver
def new_dns_record(driver):
# //*[@id="aside_menu_cdn_button"]/div[2]/div[1]
cdn_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.ID, 'aside_menu_cdn_button'))
)
cdn_button.click()
time.sleep(50)
# //*[@id="root"]/div/div[11]/div[3]/div/div/div/div[2]
# //*[@id="root"]/div/div[12]/div[3]/div/div/div/div[2]
domain_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[12]/div[3]/div/div/div/div[2]'))
)
domain_button.click()
# //*[@id="app"]/div[1]/div/aside/div[2]/ul/li[2]/div[2]/a[4]/span
dns_records_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="app"]/div[1]/div/aside/div[2]/ul/li[2]/div[2]/a[4]/span'))
)
dns_records_button.click()
# //*[@id="root"]/div/div[11]/div[3]/div/div/div[1]/div/div[1]/div/div[2]/div[3]/button/span/span[2]
new_records_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[11]/div[3]/div/div/div[1]/div/div[1]/div/div[2]/div[3]/button/span/span[2]'))
)
new_records_button.click()
# //*[@id="cdn-select"]/div/div[2]/span
# //*[@id="root"]/div/div[11]/div[3]/div/div/div[2]/div[1]/div[2]/div[3]/input
subdomain = os.environ.get('SUBDOMAIN')
if not subdomain:
subdomain = input('Enter your subdomain: ')
subdomain_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//*[@id="root"]/div/div[11]/div[3]/div/div/div[2]/div[1]/div[2]/div[3]/input'))
)
subdomain_input.send_keys(subdomain)
ip_address = os.environ.get('IP_ADDRESS')
if not ip_address:
ip_address = input('Enter your IP address: ')
# 46.102.156.91
ip_addres_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//*[@id="root"]/div/div[11]/div[3]/div/div/div[2]/div[2]/div[3]/div[2]/div/div[2]/input'))
)
ip_addres_input.send_keys(ip_addres)
# //*[@id="root"]/div/div[11]/div[3]/div/div/div[3]/div[2]/button[2]
save_records_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[11]/div[3]/div/div/div[3]/div[2]/button[2]'))
)
save_records_button.click()
def new_cloud(driver):
# //*[@id="aside_menu_server_button"]/div[2]/div[2]
server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.ID, 'aside_menu_server_button'))
)
server_button.click()
time.sleep(40)
#
new_server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[3]/div/div/a/div[1]'))
)
new_server_button.click()
# //*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button/div[1]
time.sleep(20)
next_server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button/div[1]'))
)
next_server_button.click()
time.sleep(20)
next2_server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button/div[1]'))
)
next2_server_button.click()
time.sleep(20)
next3_server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button/div[1]'))
)
next3_server_button.click()
time.sleep(20)
next4_server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button'))
)
next4_server_button.click()
time.sleep(20)
next5_server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button/div[1]'))
)
next5_server_button.click()
time.sleep(20)
# //*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button
next6_server_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[3]/div/div[2]/div/div[3]/footer/div/div[2]/div/div[2]/button'))
)
next6_server_button.click()
time.sleep(50)
driver = login_to_abrarvan()
# new_dns_record(driver)
new_cloud(driver)