import unittest import time import subprocess import urllib.parse as urlparse from setting import ( SCODOC_ADMIN_ID, SCODOC_ADMIN_PASS, BASE_URL, NOM_DPT, SCODOC_ENS_ID, SCODOC_ENS_PASS, SCODOC_CHEF_ID, SCODOC_CHEF_PASS, NAVIGATEUR, LINK_SCODOC_SERVER, BASE_NOT_SECURED_URL, ) 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 URL_MATIERE = "" URL_SEMESTRE = "" URL = BASE_URL + NOM_DPT + "/Scolarite" PRENOM_ENS = "Ens" isAdmin = True isChef = False isEns = False # Prérequis class PythonOrgSearch(unittest.TestCase): # Permet de se connecter et se remettre sur la page d'accueil avant chaque test def setUp(self): if NAVIGATEUR == "firefox": self.driver = webdriver.Firefox() else: self.driver = webdriver.Chrome() self.wait = WebDriverWait(self.driver, 10) if isAdmin: self.driver.get( "https://" + SCODOC_ADMIN_ID + ":" + SCODOC_ADMIN_PASS + "@" + BASE_NOT_SECURED_URL + "force_admin_authentication" ) else: self.driver.get(BASE_URL + NOM_DPT + "/Scolarite") if isChef: self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_CHEF_ID) self.driver.find_element_by_name("__ac_password").send_keys( SCODOC_CHEF_PASS ) self.driver.find_element_by_name("submit").click() elif isEns: self.driver.find_element_by_name("__ac_name").send_keys(SCODOC_ENS_ID) self.driver.find_element_by_name("__ac_password").send_keys( SCODOC_ENS_PASS ) self.driver.find_element_by_name("submit").click() # self.driver.get(self.url) # self.driver.find_element_by_id("name").send_keys(SCODOC_ENS_ID) # self.driver.find_element_by_id("password").send_keys(SCODOC_ENS_PASS) # self.driver.find_element_by_id("submit").click() # Test : Vérifie s'il y a un semestre en cours # @expected : La class listesems n'est pas vide et contient "Session en cours" def test_010_semestre_en_cours(self): driver = self.driver global URL driver.get(URL) # time.sleep(1) self.assertTrue( "Sessions en cours" in driver.find_element_by_class_name("listesems").text ) # Test : Vérifie si une matière existe # @expected : Le nom de la matière est présent dans le semestre préalablement testé def test_020_matiere_existante(self): driver = self.driver global URL driver.get(URL) driver.find_element_by_link_text("semestre 4").click() self.wait.until(EC.url_changes(URL)) try: driver.find_element_by_class_name("formsemestre_status_ue") global URL_SEMESTRE URL_SEMESTRE = driver.current_url self.assertTrue(True) except NoSuchElementException: self.assertFalse(False) # Test : Ajout d'un enseignant comme résponsable d'un module # @expected : Le nom de l'enseignant apparait désormais sur la page d'information du module def test_030_ajout_enseignant_sur_module(self): driver = self.driver # driver.get(BASE_URL) # driver.find_element_by_link_text("déconnecter").click() # driver.get(BASE_URL) # driver.find_element_by_id("name").send_keys(SCODOC_CHEF_ID) # driver.find_element_by_id("password").send_keys(SCODOC_CHEF_PASS) # driver.find_element_by_id("submit").click() # global URL_SEMESTRE driver.get(URL_SEMESTRE) driver.find_elemen