ScodocTestClient/06_test_moyenne.py

105 lines
3.4 KiB
Python
Raw Normal View History

import unittest
import time
import subprocess
import urllib.parse as urlparse
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
BASE_URL,
BASE_NOT_SECURED_URL,
LINK_SCODOC_SERVER,
NOM_DPT,
SCODOC_ENS_ID,
SCODOC_ENS_PASS,
SCODOC_CHEF_ID,
SCODOC_CHEF_PASS,
NAVIGATEUR,
)
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 = ""
listeEtudiant = []
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()
elif NAVIGATEUR == "chrome":
self.driver = webdriver.Chrome()
self.url = BASE_URL + NOM_DPT + "/Scolarite"
self.wait = WebDriverWait(self.driver, 10)
self.driver.get(
"https://"
+ SCODOC_ADMIN_ID
+ ":"
+ SCODOC_ADMIN_PASS
+ "@"
+ BASE_NOT_SECURED_URL
+ "force_admin_authentication"
)
self.driver.get(self.url)
def test_010_ajout_note_multiple(self):
driver = self.driver
url = self.url
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")