ScodocTestClient/creationSiteDepartement.py

54 lines
1.7 KiB
Python
Raw Normal View History

# coding: utf8
import unittest
import time
import subprocess
import HtmlTestRunner
from setting import (
SCODOC_ADMIN_ID,
SCODOC_ADMIN_PASS,
2021-07-24 08:41:26 +02:00
SCHEMA,
BASE_URL,
NOM_DPT,
LINK_SCODOC_SERVER,
2021-07-24 08:41:26 +02:00
BASE_SSH_URL,
NAVIGATEUR,
)
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.select import Select
2021-08-08 07:39:21 +02:00
URL_ROOT = SCHEMA + "://" + BASE_URL
URL_AUTH = "/".join((URL_ROOT, "auth", "login"))
URL_SCODOC8 = "/".join((URL_ROOT, "index"))
URL_HOME = "/".join((URL_ROOT, "ScoDoc", "index"))
URL_DEPT = "/".join((URL_ROOT, "ScoDoc", NOM_DPT, "Scolarite", "index_html"))
URL_ADMIN = "/".join((URL_ROOT, "ScoDoc", "admin"))
ACRONYME_FORMATION = "FormationTEST"
def main():
2021-08-08 07:39:21 +02:00
next_page = URL_HOME
if NAVIGATEUR == "firefox":
driver = webdriver.Firefox()
else:
driver = webdriver.Chrome()
2021-08-08 07:39:21 +02:00
auth_page = URL_AUTH + ("?next=" + next_page).replace("/", "%2F")
driver.get(auth_page)
driver.find_element_by_id("user_name").send_keys(SCODOC_ADMIN_ID)
driver.find_element_by_id("password").send_keys(SCODOC_ADMIN_PASS)
driver.find_element_by_id("submit").click()
time.sleep(2)
try:
2021-06-25 02:12:04 +02:00
select = Select(driver.find_element_by_id("create-dept"))
select.select_by_visible_text(NOM_DPT)
2021-06-25 02:12:04 +02:00
driver.find_element_by_id("create-dept").submit()
time.sleep(1)
driver.find_element_by_id("tf_submit").click()
time.sleep(1)
driver.close()
except NoSuchElementException:
driver.close()