import unittest
import time
import urllib.parse as urlparse
from setup import (
    SCODOC_ADMIN_ID,
    SCODOC_ADMIN_PASS,
    BASE_URL,
    NOM_DPT,
    SCODOC_ENS_ID,
    SCODOC_ENS_PASS,
    SCODOC_CHEF_ID,
    SCODOC_CHEF_PASS,
)
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 = ""


class PythonOrgSearch(unittest.TestCase):
    # Permet de se connecter et se remettre sur la page d'accueil avant chaque test
    def setUp(self):
        #chargement du script creation d'interro
        self.driver = webdriver.Firefox()
        self.url = BASE_URL + NOM_DPT + "/Scolarite"
        self.wait = WebDriverWait(self.driver, 10)
        self.driver.get(BASE_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()

    def test_010_ajout_note_multiple(self):
        driver = self.driver()
        url = self.url
        driver.find_element_by_link_text("DUT Informatique semestre 4").click()
        driver.find_element_by_link_text("M4101C").click()
        time.sleep(1)
        global urlMatiere
        urlMatiere = driver.current_url
