forked from aurelien.plancke/ScodocTestClient
160 lines
5.9 KiB
Python
160 lines
5.9 KiB
Python
import unittest
|
|
import time
|
|
import urllib.parse as urlparse
|
|
from urllib.parse import parse_qs
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.keys import Keys
|
|
from selenium.common.exceptions import NoSuchElementException
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
from selenium.webdriver.support.ui import Select, WebDriverWait
|
|
from selenium.webdriver.support.select import Select
|
|
|
|
SCODOC_ID = "enseignantUS"
|
|
SCODOC_PASS = "enseignant@"
|
|
nomDPT = "AurelienUS"
|
|
SCODOC_ADMIN_ID = "admin"
|
|
SCODOC_ADMIN_PASS = "root_pass_42"
|
|
|
|
|
|
class PythonOrgSearch(unittest.TestCase):
|
|
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
|
def setUp(self):
|
|
self.driver = webdriver.Firefox()
|
|
self.wait = WebDriverWait(self.driver, 10)
|
|
self.driver.get("https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/")
|
|
self.driver.find_element_by_id("name").send_keys(SCODOC_ID)
|
|
self.driver.find_element_by_id("password").send_keys(SCODOC_PASS)
|
|
self.driver.find_element_by_id("submit").click()
|
|
|
|
def test_01semestre_en_cours(self):
|
|
driver = self.driver
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
time.sleep(1)
|
|
self.assertTrue(
|
|
"Sessions en cours" in driver.find_element_by_class_name("listesems").text
|
|
)
|
|
|
|
def test_02matiere_existante(self):
|
|
driver = self.driver
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
|
|
time.sleep(1)
|
|
try:
|
|
driver.find_element_by_class_name("formsemestre_status_ue")
|
|
self.assertTrue(True)
|
|
except NoSuchElementException:
|
|
self.assertFalse(False)
|
|
|
|
def test_03ajout_enseignant_sur_module(self):
|
|
driver = self.driver
|
|
self.driver.get(
|
|
"https://"
|
|
+ SCODOC_ADMIN_ID
|
|
+ ":"
|
|
+ SCODOC_ADMIN_PASS
|
|
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
|
|
)
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
|
|
driver.find_element_by_link_text("M4101C").click()
|
|
time.sleep(1)
|
|
driver.find_element_by_partial_link_text("modifier les enseignants").click()
|
|
time.sleep(1)
|
|
driver.find_element_by_id("ens_id").send_keys("ENSEIGNANT Test (enseignantUS)")
|
|
driver.find_element_by_id("tf_submit").click()
|
|
time.sleep(1)
|
|
self.assertTrue("Enseignants du" in driver.page_source)
|
|
self.assertTrue(SCODOC_ID in driver.page_source)
|
|
|
|
def test_04interro_existante(self):
|
|
driver = self.driver
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
|
|
driver.find_element_by_link_text("M4101C").click()
|
|
time.sleep(1)
|
|
self.assertTrue(
|
|
"Module" in driver.find_element_by_class_name("formsemestre").text
|
|
)
|
|
|
|
def test_05entree_note(self):
|
|
driver = self.driver
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
|
|
driver.find_element_by_link_text("M4101C").click()
|
|
time.sleep(1)
|
|
driver.find_element_by_link_text("saisir notes").click()
|
|
time.sleep(1)
|
|
elements = driver.find_elements_by_class_name("note")
|
|
for element in elements:
|
|
element.send_keys("12")
|
|
time.sleep(5)
|
|
|
|
def test_06ajout_note_incomplete(self):
|
|
driver = self.driver
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
|
|
driver.find_element_by_link_text("M4101C").click()
|
|
time.sleep(1)
|
|
driver.find_element_by_xpath(
|
|
"//input[@title='Saisie des notes' and @type='image']"
|
|
).click()
|
|
time.sleep(5)
|
|
|
|
def test_07suppression_note(self):
|
|
driver = self.driver
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
|
|
driver.find_element_by_link_text("M4101C").click()
|
|
time.sleep(1)
|
|
driver.find_element_by_link_text("saisir notes").click()
|
|
time.sleep(1)
|
|
elements = driver.find_elements_by_class_name("note")
|
|
for element in elements:
|
|
element.send_keys("12")
|
|
time.sleep(5)
|
|
|
|
def test_08suppression_enseignant_sur_module(self):
|
|
driver = self.driver
|
|
self.driver.get(
|
|
"https://"
|
|
+ SCODOC_ADMIN_ID
|
|
+ ":"
|
|
+ SCODOC_ADMIN_PASS
|
|
+ "@scodoc-dev-iutinfo.univ-lille.fr/force_admin_authentication"
|
|
)
|
|
driver.get(
|
|
"https://scodoc-dev-iutinfo.univ-lille.fr/ScoDoc/" + nomDPT + "/Scolarite"
|
|
)
|
|
driver.find_element_by_link_text("DUT Informatique semestre 4").click()
|
|
driver.find_element_by_link_text("M4101C").click()
|
|
time.sleep(1)
|
|
driver.find_element_by_partial_link_text("modifier les enseignants").click()
|
|
time.sleep(1)
|
|
elements = driver.find_elements_by_link_text("supprimer")
|
|
for element in elements:
|
|
element.click()
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
self.assertTrue(SCODOC_ID not in driver.page_source)
|
|
|
|
# ferme la fenetre
|
|
def tearDown(self):
|
|
self.driver.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() |