2021-05-20 20:39:00 +02:00
|
|
|
import unittest
|
|
|
|
import time
|
2021-06-07 16:48:11 +02:00
|
|
|
import subprocess
|
2021-05-20 20:39:00 +02:00
|
|
|
import urllib.parse as urlparse
|
2021-06-07 16:48:11 +02:00
|
|
|
from setting import (
|
2021-05-20 20:39:00 +02:00
|
|
|
SCODOC_ADMIN_ID,
|
|
|
|
SCODOC_ADMIN_PASS,
|
|
|
|
BASE_URL,
|
2021-06-07 16:48:11 +02:00
|
|
|
BASE_NOT_SECURED_URL,
|
|
|
|
LINK_SCODOC_SERVER,
|
2021-05-20 20:39:00 +02:00
|
|
|
NOM_DPT,
|
|
|
|
SCODOC_ENS_ID,
|
|
|
|
SCODOC_ENS_PASS,
|
|
|
|
SCODOC_CHEF_ID,
|
|
|
|
SCODOC_CHEF_PASS,
|
2021-06-07 16:48:11 +02:00
|
|
|
NAVIGATEUR,
|
2021-05-20 20:39:00 +02:00
|
|
|
)
|
|
|
|
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
|
|
|
|
|
|
|
|
urlMatiere = ""
|
2021-06-07 16:48:11 +02:00
|
|
|
listeEtudiant = []
|
2021-05-20 20:39:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PythonOrgSearch(unittest.TestCase):
|
|
|
|
# Permet de se connecter et se remettre sur la page d'accueil avant chaque test
|
|
|
|
def setUp(self):
|
2021-06-07 16:48:11 +02:00
|
|
|
if NAVIGATEUR == "firefox":
|
|
|
|
self.driver = webdriver.Firefox()
|
|
|
|
elif NAVIGATEUR == "chrome":
|
|
|
|
self.driver = webdriver.Chrome()
|
2021-05-20 20:39:00 +02:00
|
|
|
self.url = BASE_URL + NOM_DPT + "/Scolarite"
|
|
|
|
self.wait = WebDriverWait(self.driver, 10)
|
2021-06-07 16:48:11 +02:00
|
|
|
self.driver.get(
|
|
|
|
"https://"
|
|
|
|
+ SCODOC_ADMIN_ID
|
|
|
|
+ ":"
|
|
|
|
+ SCODOC_ADMIN_PASS
|
|
|
|
+ "@"
|
|
|
|
+ BASE_NOT_SECURED_URL
|
|
|
|
+ "force_admin_authentication"
|
|
|
|
)
|
|
|
|
self.driver.get(self.url)
|
2021-05-20 20:39:00 +02:00
|
|
|
|
|
|
|
def test_010_ajout_note_multiple(self):
|
2021-06-07 16:48:11 +02:00
|
|
|
driver = self.driver
|
2021-05-20 20:39:00 +02:00
|
|
|
url = self.url
|
2021-06-07 16:48:11 +02:00
|
|
|
driver.find_element_by_link_text("semestre 1").click()
|
|
|
|
matiereAvecEvaluation = driver.find_elements_by_xpath(
|
|
|
|
"//a[contains(text(),'1 prévues, 0 ok')]"
|
|
|
|
)
|
|
|
|
global listeEtudiant
|
|
|
|
linkAddNote = "formnotes_note_"
|
|
|
|
|
|
|
|
for evaluation in matiereAvecEvaluation:
|
|
|
|
URL = driver.current_url
|
|
|
|
evaluation.click()
|
|
|
|
self.wait.until(EC.url_changes(URL))
|
|
|
|
URL_SEMESTRE = driver.current_url
|
|
|
|
driver.find_element_by_xpath("//a[contains(@href,'saisie_notes?')]").click()
|
|
|
|
self.wait.until(EC.url_changes(URL_SEMESTRE))
|
|
|
|
for champs in driver.find_elements_by_xpath(
|
|
|
|
"//input[contains(@id,'" + linkAddNote + "')]"
|
|
|
|
):
|
|
|
|
champs.send_keys(12)
|
|
|
|
idChamp = champs.get_attribute("id")
|
|
|
|
idEtud = idChamp[len(linkAddNote) : len(idChamp)]
|
|
|
|
if idEtud not in listeEtudiant:
|
|
|
|
listeEtudiant.append(idEtud)
|
|
|
|
URL = driver.current_url
|
|
|
|
driver.find_element_by_id("formnotes_submit").click()
|
|
|
|
self.wait.until(EC.url_changes(URL))
|
|
|
|
driver.get(URL_SEMESTRE)
|
|
|
|
for etudiant in listeEtudiant:
|
|
|
|
searchBar = driver.find_element_by_id("in-expnom")
|
|
|
|
searchBar.send_keys(etudiant)
|
|
|
|
searchBar.submit()
|
|
|
|
self.assertTrue(driver.find_element_by_id("rcp_moy").text == "12")
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.driver.close()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if NAVIGATEUR == "firefox":
|
|
|
|
driver = webdriver.Firefox()
|
|
|
|
else:
|
|
|
|
driver = webdriver.Chrome()
|
|
|
|
cmdProcess = ["./scriptCreationDepartement.sh", LINK_SCODOC_SERVER, NOM_DPT]
|
|
|
|
process = subprocess.Popen(cmdProcess)
|
|
|
|
process.wait()
|
|
|
|
cmdProcess = [
|
|
|
|
"./scriptExecution.sh",
|
|
|
|
LINK_SCODOC_SERVER,
|
|
|
|
NOM_DPT,
|
|
|
|
"test_scenario3_formation.py",
|
|
|
|
]
|
|
|
|
process = subprocess.Popen(cmdProcess)
|
|
|
|
process.wait()
|
|
|
|
unittest.main(warnings="ignore")
|