-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnrollBot.py
58 lines (50 loc) · 2.37 KB
/
EnrollBot.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
# Generated by Selenium IDE
import pytest
import time
import json
import config
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class TestTest():
# user Config
userName = config.CONFIG['USERNAME_STR']
passWord = config.CONFIG['PASSWORD_STR']
courses = config.CONFIG['COURSES_STR']
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def wait_for_window(self, timeout = 2):
time.sleep(round(timeout / 1000))
wh_now = self.driver.window_handles
wh_then = self.vars["window_handles"]
if len(wh_now) > len(wh_then):
return set(wh_now).difference(set(wh_then)).pop()
def test_test(self):
self.driver.get("https://www.mtsac.edu/")
self.driver.set_window_size(1294, 1040)
self.vars["window_handles"] = self.driver.window_handles
self.driver.find_element(By.LINK_TEXT, "Portal Login").click()
self.vars["win7466"] = self.wait_for_window(2000)
self.driver.switch_to.window(self.vars["win7466"])
self.driver.find_element(By.ID, "username").send_keys(userName)
self.driver.find_element(By.ID, "password").send_keys(passWord)
self.driver.find_element(By.CSS_SELECTOR, ".wr-btn").click()
self.driver.find_element(By.CSS_SELECTOR, "#layout_17 .nav-label").click()
self.vars["window_handles"] = self.driver.window_handles
self.driver.find_element(By.CSS_SELECTOR, "p:nth-child(1) > a:nth-child(9) > span").click()
self.vars["win9455"] = self.wait_for_window(2000)
self.driver.switch_to.window(self.vars["win9455"])
self.driver.find_element(By.CSS_SELECTOR, ".pagebodydiv input").click()
self.driver.find_element(By.ID, "crn_id1").send_keys(courses[0])
self.driver.find_element(By.ID, "crn_id2").send_keys(courses[1])
self.driver.find_element(By.ID, "crn_id3").send_keys(courses[2])
self.driver.find_element(By.ID, "crn_id4").send_keys(courses[3])
self.driver.find_element(By.ID, "crn_id5").send_keys(courses[4])
self.driver.find_element(By.CSS_SELECTOR, "input:nth-child(28)").click()