From b7f3830b2fd8794cbe2a8d3442051203cb3d26d6 Mon Sep 17 00:00:00 2001 From: aurelien Date: Fri, 4 Jun 2021 20:58:14 +0200 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20tests=20saisie=20note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 05_saisie_note_test.py | 91 ++++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 21 deletions(-) diff --git a/05_saisie_note_test.py b/05_saisie_note_test.py index 02d6516..0c23b94 100644 --- a/05_saisie_note_test.py +++ b/05_saisie_note_test.py @@ -27,6 +27,7 @@ URL_MATIERE = "" URL_SEMESTRE = "" URL = BASE_URL + NOM_DPT + "/Scolarite" PRENOM_ENS = "Ens" +PRENOM_CHEF = "Chef" isAdmin = True isChef = False isEns = False @@ -52,13 +53,17 @@ class PythonOrgSearch(unittest.TestCase): else: self.driver.get(BASE_URL + NOM_DPT + "/Scolarite") if isChef: - driver.find_element_by_name("__ac_name").send_keys(SCODOC_CHEF_ID) - driver.find_element_by_name("__ac_password").send_keys(SCODOC_CHEF_PASS) - driver.find_element_by_name("submit").click() + 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: - driver.find_element_by_name("__ac_name").send_keys(SCODOC_ENS_ID) - driver.find_element_by_name("__ac_password").send_keys(SCODOC_ENS_PASS) - driver.find_element_by_name("submit").click() + 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) @@ -110,19 +115,50 @@ class PythonOrgSearch(unittest.TestCase): driver.find_element_by_partial_link_text("modifier les enseignants").click() time.sleep(1) constructIDEns = ( - SCODOC_ENS_ID.upper() - + " " - + PRENOM_ENS - + " (" - + SCODOC_ENS_ID.lower() - + ")" + SCODOC_ENS_ID.upper() + " " + PRENOM_ENS + " (" + SCODOC_ENS_ID + ")" ) driver.find_element_by_id("ens_id").send_keys(constructIDEns) driver.find_element_by_id("tf_submit").click() time.sleep(1) driver.get(URL_MATIERE) + professeurDansModule = driver.find_elements_by_class_name("ens_Dans_Module") # self.assertTrue("Enseignants du" in driver.page_source) - self.assertTrue(SCODOC_ENS_ID in driver.page_source) + time.sleep(5) + professeurString = [] + for professeur in professeurDansModule: + professeurString.append(professeur.text) + for professeurS in professeurString: + print(SCODOC_ENS_ID.lower() + " " + professeurS.lower()) + print(professeurS.lower().find(SCODOC_ENS_ID.lower() + " e.")) + if professeurS.lower().find(SCODOC_ENS_ID.lower() + " e."): + self.assertTrue(True) + + self.assertFalse(True) + + def test_031_changement_responsable_sur_module(self): + driver = self.driver + global URL_MATIERE + driver.get(URL_MATIERE) + driver.find_element_by_xpath( + "//a[contains(@href,'edit_moduleimpl_resp?')]" + ).click() + self.wait.until(EC.url_changes(URL_MATIERE)) + constructIdResponsable = ( + SCODOC_CHEF_ID.upper() + + " " + + PRENOM_CHEF + + " (" + + SCODOC_CHEF_ID.lower() + + ")" + ) + idInput = driver.find_element_by_name("responsable_id") + idInput.clear() + idInput.send_keys(constructIdResponsable) + driver.find_element_by_id("tf_submit").click() + time.sleep(1) + driver.get(URL_MATIERE) + nomResponsable = driver.find_element_by_id("ens_Responsable") + self.assertTrue(SCODOC_CHEF_ID.lower() in nomResponsable.text.lower()) # Test : Création d'une interrogation en tant que chef des études # @eexpected : L'interrogation apparait désormais dans ce module @@ -198,10 +234,12 @@ class PythonOrgSearch(unittest.TestCase): if element.get_attribute("value") == "": element.send_keys(15) driver.find_element_by_id("formnotes_submit").click() - driver.find_element_by_id("in-expnom").sendKeys("SEMESTRE47") + time.sleep(5) + element = driver.find_element_by_id("in-expnom") + element.send_keys("SEMESTRE47") element.submit() time.sleep(5) - self.assertTrue("12" in driver.find_element_by_id("rcp_moy").text) + self.assertTrue("12" in driver.find_element_by_class_name("rcp_moy").text) # Test : Suppresion des notes pour tout les étudiants concernés dans une interrogation # @expected : La moyenne ne s'affiche plus, "afficher" disparait de la page d'information de l'interrogation @@ -223,6 +261,10 @@ class PythonOrgSearch(unittest.TestCase): self.assertFalse(False) except NoSuchElementException: self.assertTrue(True) + global isAdmin + isAdmin = True + global isEns + isEns = False # Test : SUppression d'une interrogation par le chef des études # @expected : L'interrogation n'apparait plus sur le module, les notes sont supprimées également @@ -234,6 +276,8 @@ class PythonOrgSearch(unittest.TestCase): time.sleep(1) driver.find_element_by_link_text("Créer nouvelle évaluation").click() time.sleep(1) + driver.find_element_by_name("jour").clear() + driver.find_element_by_name("jour").send_keys("30/05/2021") driver.find_element_by_id("tf_description").send_keys(descriptionInterrogation) driver.find_element_by_id("tf_coefficient").send_keys("2") driver.find_element_by_id("tf_submit").click() @@ -262,6 +306,8 @@ class PythonOrgSearch(unittest.TestCase): time.sleep(1) time.sleep(1) driver.get(URL_MATIERE) + print(SCODOC_ENS_ID) + time.sleep(10) self.assertTrue(SCODOC_ENS_ID not in driver.page_source) # Test : Suppresion du reste des interrogations sans notes @@ -270,15 +316,18 @@ class PythonOrgSearch(unittest.TestCase): driver = self.driver driver.get(URL_MATIERE) time.sleep(1) - elements = driver.find_elements_by_class_name("delete_img") + elements = driver.find_elements_by_xpath( + "//a[contains(@href,'evaluation_delete?')]" + ) while elements: elements[0].click() - time.sleep(1) driver.find_element_by_id("tf_submit").click() - time.sleep(1) - driver.get(URL_MATIERE) - time.sleep(1) - elements = driver.find_elements_by_class_name("delete_img") + self.wait.until(EC.url_changes(URL)) + driver.find_element_by_partial_link_text("Continuer").click() + self.wait.until(EC.url_changes(URL)) + elements = driver.find_elements_by_xpath( + "//a[contains(@href,'evaluation_delete?')]" + ) # ferme la fenetre et fais du clean up def tearDown(self):