-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_Gmail.py
More file actions
80 lines (54 loc) · 1.87 KB
/
test_Gmail.py
File metadata and controls
80 lines (54 loc) · 1.87 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
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 08:56:51 2018
@author: Tai
"""
import time
from Util import ReadExcel, logInfo
from WebTools import browserSetup, browserClose
from Gmail_POM import Gmail_SigninUserID, Gmail_SigninPassword, Gmail_Compose
def signinGmail(driver, userid, password):
logInfo("siginGmail() ")
g = Gmail_SigninUserID(driver, userid)
g.submitUserID()
logInfo("Sleep for few seconds")
time.sleep(3)
g1 = Gmail_SigninPassword(driver, password)
g1.submitPassword()
def composeGmail(driver, mailto, subject, content):
c = Gmail_Compose(driver)
c.sendEmail(mailto, subject, content)
logInfo("Sleep for few seconds")
time.sleep(3)
c.logOut()
def getUserLogin():
logInfo("initSetup()")
logInfo("Retrieve userid/password from excel")
f = "C:\\2018\\edureka\\selenium\\INPUT\\gmail_input.xlsx"
sh = ReadExcel(f, 'Sheet1')
userid = sh.get_data('A1')
password = sh.get_data('B1')
#logInfo("userid : " + userid + " password : " + password)
return (userid, password)
def startChromeBrowser():
driverPath = "C:\\2018\\Python\\selenium\\chromedriver.exe"
url = "https://www.gmail.com/"
driver = browserSetup(driverPath, url)
return driver
def main():
userdata = getUserLogin()
print(userdata)
driver = startChromeBrowser()
logInfo("Test-1 : siginGmail() ")
signinGmail(driver, userdata[0], userdata[1])
logInfo("Sleep for few seconds")
time.sleep(10)
logInfo("Test-2 : composeGmail() and logOut() ")
mailto = "taislu@hotmail.com"
subject = "Automated Gmail test"
content = "This is an email sent via Selenium."
composeGmail(driver, mailto, subject, content)
browserClose(driver)
logInfo("DONE!")
if __name__ == '__main__':
main()