forked from DevendraSS/Automation-In-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomation_draft.py
More file actions
196 lines (142 loc) · 7.34 KB
/
automation_draft.py
File metadata and controls
196 lines (142 loc) · 7.34 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import time
import tkinter as tk
from selenium import webdriver
from selenium.webdriver.common.by import By
from tkinter import messagebox
from tkinter import *
driver = webdriver.Chrome()
def login(username, password):
# selenium code to open the window and
win.destroy()
driver.maximize_window()
driver.get("http://moodle.mitsgwalior.in/")
link = driver.find_element(By.LINK_TEXT, "Log in")
link.click()
driver.find_element(By.ID, "username").send_keys(username)
driver.find_element(By.ID, "password").send_keys(password)
driver.find_element(By.ID, "loginbtn").click()
def teachers(teachnames):
print(teachnames)
if teachnames.lower() == "dkj":
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=344")
elif teachnames.lower() == "aso":
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=355")
elif teachnames.lower() == "psharma":
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=366")
elif teachnames.lower() == "sk":
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=530")
elif teachnames.lower() == "ashish":
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=771")
elif teachnames.lower() == "vs":
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=724")
def prompt(userchoice):
x = userchoice.split()
if "attendance" in x:
win2.destroy()
root = Tk()
root.geometry("500x500")
root.title("ATTENDANCE")
enter_info = Label(root, text="Moodle Automation", bg="lightgrey", font=("Arial", 14))
enter_info.grid(row=0, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
enter_info = Label(root, text="version = 0.1.1", bg="lightgrey")
enter_info.grid(row=1, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
# For entering a text
Label(root, text="Teacher Name ").grid(row=2)
Label(root, text="Teacher Subject ").grid(row=3)
teacher_entry = Entry(root, width=35)
teacher_subject = Entry(root, width=35)
teacher_entry.grid(row=2, column=2, padx=20, pady=20)
teacher_subject.grid(row=3, column=2, padx=20, pady=20)
# Button which says Click Here
button1 = Button(root, text="Click Here",
command=lambda: teacher_attendance(teacher_entry.get(), teacher_subject.get())).grid(row=4,
column=2,
sticky=tk.W,
pady=25,
padx=25)
root.mainloop()
elif "page" in x:
win2.destroy()
var = Tk()
var.geometry("500x500")
var.title("Course Page")
canvas = Canvas(var)
canvas.create_text(200, 180, text="Moodle Automation", fill="black", font=('Helvetica 15 bold'))
canvas.create_text(200, 220, text="Version: 0.0.1α", fill="black", font=('Helvetica 10 bold'))
canvas.create_text(200, 250, text="Who's page do you want to access?", fill="black", font=('Helvetica 15 bold'))
canvas.pack()
# For entering a text
userentry = Entry(var)
userentry.pack()
# Button which says Click Here
button1 = Button(var, text="Click Here", command=lambda: teachers(userentry.get()))
button1.pack()
var.mainloop()
def teacher_attendance(teachername, subject):
teachersplit = teachername.split()
subjsplit = subject.split()
if "dkj" in teachersplit and "transform" in subjsplit:
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=344§ion=2")
elems = driver.find_element(By.CLASS_NAME, "aalink")
if len(str(elems)) > 0:
driver.get("http://moodle.mitsgwalior.in/mod/attendance/view.php?id=78375")
else:
messagebox.showinfo("Access Denied", "You are not enrolled in this Course")
elif "dkj" in teachersplit and "nec" in subjsplit:
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=344§ion=1")
elems = driver.find_element(By.CLASS_NAME, "aalink")
if len(str(elems)) > 0:
driver.get("")
else:
messagebox.showinfo("Access Denied", "You are not enrolled in this Course")
elif "skb" in teachersplit and "python" in subjsplit:
#add this to the file which you have made
# driver.get("http://moodle.mitsgwalior.in/course/view.php?id=590§ion=4")
driver.get("http://moodle.mitsgwalior.in/mod/attendance/view.php?id=78742")
driver.get("http://moodle.mitsgwalior.in/mod/attendance/attendance.php?sessid=171308&sesskey=SrYwK9fHuP")
driver.find_element(By.CLASS_NAME, "form-check-input").click()
driver.find_element(By.CLASS_NAME, "btn-btn-primary").click()
win = Tk()
# customization of the tkinter window
win.title("Moodle Automation")
win.geometry("400x350")
win.maxsize(500, 500)
win.config(bg="lightgrey")
enter_info = Label(win, text="Moodle Automation", bg="lightgrey", font=("Arial", 14))
enter_info.grid(row=0, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
enter_info = Label(win, text="version = 0.1.1", bg="lightgrey")
enter_info.grid(row=1, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
Label(win, text="Username").grid(row=2)
Label(win, text="Password").grid(row=3)
# userinput and password
userinput = Entry(win, width=35)
password = Entry(win, width=35, show="*")
userinput.grid(row=2, column=2, padx=20, pady=20)
password.grid(row=3, column=2, padx=20, pady=20)
# Button which says Click Here
tk.Button(win, text="Click Here to Start", command=lambda: login(userinput.get(), password.get())).grid(row=4, column=2,
sticky=tk.W,
pady=25,
padx=25)
win.mainloop()
# window for user entry
win2 = Tk()
# customization of the tkinter window
win2.title("Moodle Automation")
win2.geometry("350x300")
win2.maxsize(500, 500)
win2.config(bg="lightgrey")
enter_info1 = Label(win2, text="Moodle Automation", bg="lightgrey", font=("Arial", 14))
enter_info1.grid(row=0, column=4, rowspan=1, columnspan=4, padx=10, pady=10)
enter_info3 = Label(win2, text="version = 0.1.1", bg="lightgrey")
enter_info3.grid(row=1, column=3, rowspan=1, columnspan=4, padx=10, pady=5, ipadx=5, ipady=5)
enter_info2 = Label(win2, text="What would you like to access?", bg="lightgrey", font=("Arial", 13))
enter_info2.grid(row=2, column=3, rowspan=1, columnspan=4, padx=10, ipady=5, ipadx=10)
# userinput and password
userinput = Entry(win2, width=35)
userinput.grid(row=3, column=5, padx=15, pady=15)
# Button which says Click Here
tk.Button(win2, text="Click Here", command=lambda: prompt(userinput.get())).grid(row=4, column=5, sticky=tk.W, pady=10,
padx=80, ipadx=5, ipady=5)
win2.mainloop()
time.sleep(5000)