-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIEEEreg.py
More file actions
159 lines (143 loc) · 5.78 KB
/
IEEEreg.py
File metadata and controls
159 lines (143 loc) · 5.78 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
''' Module for Automated Script for BMSCE IEEE Registrations '''
# Requires Selenium, Gecko and Mozilla Firefox
# @author: Saurabh Chheda
import time
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException, ElementNotInteractableException
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
def put_tabs(window, no_of_tabs):
''' Function to put tabs '''
for i in range(no_of_tabs):
ActionChains(window).key_down(Keys.TAB).key_up(Keys.TAB).perform()
def select_option(window, option):
''' Function to select nth option '''
for i in range(option):
ActionChains(window).key_down(Keys.DOWN).key_up(Keys.DOWN).perform()
def fill_input(window, input_id, value):
''' Function fills in textboxes with value '''
continue_link = window.find_element_by_id(input_id)
continue_link.click()
continue_link.clear()
continue_link.send_keys(value)
def fill_select(window, select_id, option_value):
''' Function to select an option '''
select_el = Select(window.find_element_by_id(select_id))
select_el.select_by_value(option_value)
def fill_after_tabs(window, no_of_tabs, value):
''' Function to add tabs and then fill an input '''
put_tabs(window, no_of_tabs)
ActionChains(window).send_keys(value).perform()
def login(window, email):
''' Function to log in '''
try:
fill_input(window, 'username', email)
fill_input(window, 'password', 'bmsceieee17')
continue_link = window.find_element_by_id('ppctLoginSubmit')
continue_link.click()
except NoSuchElementException:
time.sleep(2)
login(window, email)
except ElementNotInteractableException:
time.sleep(2)
login(window, email)
def fill_contact_information(window):
''' Function to fill in address '''
try:
address_type = window.find_element_by_id("contact-info_customer_addresses_0__addressType_code-3")
address_type.click()
fill_select(window, "country", "IN")
time.sleep(2)
fill_after_tabs(window, 9, 'B.M.S. College of Engineering')
fill_after_tabs(window, 1, 'P.O. Box No.: 1908, Bull Temple Road')
fill_after_tabs(window, 2, 'Bangalore')
fill_after_tabs(window, 2, '560019')
put_tabs(window, 8)
ActionChains(window).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()
except NoSuchElementException:
time.sleep(2)
fill_contact_information(window)
def fill_educational_information(window, year):
''' Function to fill educational details '''
# @debug
# time.sleep(5)
# window.execute_script('window.scrollTo(0, 1000)')
# time.sleep(5)
#
time.sleep(10)
try:
put_tabs(window, 2)
ActionChains(window).key_down(Keys.ESCAPE).key_up(Keys.ESCAPE).perform()
# window.find_element_by_id('AttestationInfo').click()
fill_after_tabs(window, 8, "B.M")
time.sleep(2)
put_tabs(window, 3)
ActionChains(window).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()
time.sleep(4)
put_tabs(window, 1)
ActionChains(window).key_down(Keys.SPACE).key_up(Keys.SPACE).perform()
put_tabs(window, 1)
select_option(window, 7)
put_tabs(window, 1)
select_option(window, 136)
put_tabs(window, 1)
select_option(window, 6)
put_tabs(window, 1)
select_option(window, int(year)-2017)
put_tabs(window, 2)
select_option(window, 3)
put_tabs(window, 1)
select_option(window, 16)
put_tabs(window, 2)
ActionChains(window).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()
except NoSuchElementException:
time.sleep(2)
fill_educational_information(window, year)
def fill_additional_details(window):
''' Function to fill in additional details '''
try:
put_tabs(window, 7)
ActionChains(window).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()
time.sleep(5)
window.find_element_by_id('mbMCAddMemProdBtn').click()
window.execute_script('window.scrollTo(0, 2400)')
time.sleep(12)
window.find_element_by_id('TechnicallyCurrent').click()
window.find_element_by_id('CareerOpurtunities').click()
window.find_element_by_id('ExpandProfessionalNetwork').click()
window.find_element_by_id('ConnectToLocalActivities').click()
window.find_element_by_id('HumanitarianPrograms').click()
window.find_element_by_id('Discounts').click()
fill_select(window, 'member-referral', "Member referral")
fill_input(window, 'referring-mem-name', 'Saurabh Sunil Chheda')
fill_input(window, 'referring-mem-number', '93651909')
put_tabs(window, 1)
ActionChains(window).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()
except NoSuchElementException:
time.sleep(2)
fill_additional_details(window)
def logout(window):
''' Logs user out '''
time.sleep(10)
username = window.find_element_by_id('mn-ieee-username')
logout_button = window.find_element_by_id('mn-signout-link')
ActionChains(window).move_to_element(username).click(logout_button).perform()
time.sleep(10)
def main():
''' Initialization function '''
csv = open("todo.csv", 'r')
for record in csv:
window = webdriver.Firefox()
record = record.split(',')
email = record[0]
year_of_grad = record[1]
window.get("http://www.ieee.org/go/join_student")
login(window, email)
fill_contact_information(window)
fill_educational_information(window, year_of_grad)
fill_additional_details(window)
window.close()
csv.close()
if __name__ == "__main__":
main()