-
Notifications
You must be signed in to change notification settings - Fork 2
/
mailServerConfig.py
151 lines (93 loc) · 4.24 KB
/
mailServerConfig.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
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
from config import CONFIG
from selenium.webdriver.chrome.options import Options
import time, login, os, sys
import logging
from selenium.webdriver.common.keys import Keys
script = os.path.basename(sys.argv[0])
logging.basicConfig(filename='./files/test_logs/%s.log' % script, format='%(asctime)s %(message)s', level=logging.INFO)
logger = logging.getLogger('test')
if CONFIG.WEBDRIVER == "Chrome":
_chrome_options = Options()
_chrome_options.add_argument("--start-fullscreen")
driver = webdriver.Chrome(chrome_options=_chrome_options)
elif CONFIG.WEBDRIVER == "Firefox":
driver = webdriver.Firefox()
else:
print('No valid Webdrive was provided. ')
driver.implicitly_wait(CONFIG.waittime)
# time.sleep(2)
email_list = ['[email protected]',
]
host = CONFIG.HOST
def notification_mgmt(emailadd):
if 'feed-health' not in driver.current_url:
driver.get(host + "management/notifications/feed-health")
time.sleep(2)
driver.find_element_by_id("email-distribution-list-input").clear()
driver.find_element_by_id("email-distribution-list-input").send_keys(emailadd)
driver.find_element_by_id("email-distribution-list-input").send_keys(Keys.ENTER)
def enable_notification():
if 'feed-health' not in driver.current_url:
driver.get(host + "management/notifications/feed-health")
time.sleep(2)
try:
driver.find_element_by_xpath("//a[@class='btn text'][@ng-click='toggleEnabled()']").click()
# driver.find_element_by_xpath("(.//*[normalize-space(text()) and normalize-space(.)='Feed Health Notifications'])[1]/following::i[1]").click()
except Exception as e:
print ('Notifications already enabled.')
def disable_notifications():
if 'feed-health' not in driver.current_url:
driver.get(host + "management/notifications/feed-health")
time.sleep(2)
try:
driver.find_element_by_xpath(
"(.//*[normalize-space(text()) and normalize-space(.)='Disabled'])[1]/following::i[1]").click()
except Exception as e:
print ('Notifications already disabled')
def server_config():
driver.get(host + "management/notifications/mail")
time.sleep(5)
# Server name
driver.find_element_by_id("server-name-field").clear()
driver.find_element_by_id("server-name-field").send_keys('smtp.gmail.com')
# SSL method
driver.find_element_by_id("ssl-field").click()
driver.find_element_by_xpath("//a[contains(text(),'SSL')]").click()
# Credentials
driver.find_element_by_id("username-field").clear()
driver.find_element_by_id("username-field").send_keys('[email protected]')
# from_email
driver.find_element_by_id("from-address-field").clear()
driver.find_element_by_id("from-address-field").send_keys('[email protected]')
driver.find_element_by_xpath("//input[@type='password']").clear()
driver.find_element_by_xpath("//input[@type='password']").send_keys("TestingSMTP123TestingSMTP")
driver.find_element_by_xpath("//div//button[@class='btn primary'][contains(text(),'Save Changes')]").click()
def test_email(emailadd):
if "management/notifications/mail" not in driver.current_url:
driver.get(host + "management/notifications/mail")
time.sleep(2)
driver.find_element_by_id("testEmail-field").clear()
driver.find_element_by_id("testEmail-field").send_keys(emailadd)
driver.find_element_by_xpath("//button[@class='btn success less-padding'][contains(text(),' Save and Send Test Email')]").click()
#### Test execution steps starts here!!!!!
login.login(logger, host, driver, usr=CONFIG.USER[0], pssword=CONFIG.USER[1], SAML=CONFIG.SAML)
logger.info('Start Mail Server Config test')
time.sleep(3)
#### Setup email connection settings
server_config()
#### Test connection settings
test_email('[email protected]')
#### Add emails to notification list
for email in email_list:
notification_mgmt(email)
time.sleep(3)
#### Enable email notifications
enable_notification()
time.sleep(3)
login.logout(logger, wdriver=driver)
driver.quit()