Commit c3323081 authored by GuiΩ's avatar GuiΩ
Browse files

execute Selenium with django.test

parent 7a054c0b
Pipeline #386507 failed with stages
in 2 minutes and 9 seconds
......@@ -17,7 +17,7 @@ frontend:
paths:
- public/
tests-backend:
tests:
stage: test
image: python:3.7
script:
......@@ -25,21 +25,6 @@ tests-backend:
- apt install python3 python3-pip virtualenvwrapper -qy
- virtualenv --python=python3 venv/
- source venv/bin/activate
- pip install -r requirements.txt
tests-frontend:
stage: test
image: python:3.7
script:
- apt update -qy
- apt install python3 python3-pip virtualenvwrapper -qy
- virtualenv --python=python3 venv/
- source venv/bin/activate
- pip install -r requirements.txt
- pip install -r tests_requirements.txt
- wget https://github.com/mozilla/geckodriver/releases/download/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz
- tar -xvzf geckodriver-v0.29.0-linux64.tar.gz
- mv geckodriver venv/bin/
- pytest am/tests/frontend
- pip install -r requirements.txt
- python manage.py test
# Generated by Selenium IDE
from django.test import LiveServerTestCase
from django.test import override_settings
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.firefox import GeckoDriverManager
class TestConnection():
def setup_method(self, method):
self.driver = webdriver.Firefox()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
@override_settings(DEBUG=True)
class TestConnection(LiveServerTestCase):
def setUp(self):
self.selenium = webdriver.Firefox(executable_path=GeckoDriverManager().install())
def test_connection(self):
self.driver.get("http://127.0.0.1:8000/am/")
self.driver.set_window_size(1276, 664)
self.driver.find_element(By.LINK_TEXT, "Connexion").click()
self.driver.find_element(By.ID, "id_username").click()
self.driver.find_element(By.ID, "id_username").send_keys("gclaus")
self.driver.find_element(By.ID, "id_password").send_keys("ZeBulon73")
self.driver.find_element(By.CSS_SELECTOR, "button").click()
WebDriverWait(self.driver, 10).until(
self.selenium.get("http://127.0.0.1:8000/am/")
self.selenium.set_window_size(1276, 664)
self.selenium.find_element(By.LINK_TEXT, "Connexion").click()
self.selenium.find_element(By.ID, "id_username").click()
self.selenium.find_element(By.ID, "id_username").send_keys("gclaus")
self.selenium.find_element(By.ID, "id_password").send_keys("ZeBulon73")
self.selenium.find_element(By.CSS_SELECTOR, "button").click()
WebDriverWait(self.selenium, 10).until(
expected_conditions.element_to_be_clickable((By.CSS_SELECTOR, ".open > ul > .closed:nth-child(1) > span")))
self.driver.find_element(By.CSS_SELECTOR, ".open > ul > .closed:nth-child(1) > span").click()
self.driver.find_element(By.CSS_SELECTOR, ".open > ul > .closed:nth-child(1) > span").click()
self.driver.find_element(By.CSS_SELECTOR, ".open > ul > .feuille:nth-child(1) > span").click()
elements = self.driver.find_elements(By.CSS_SELECTOR, "img[alt=\'question 2644\']")
self.selenium.find_element(By.CSS_SELECTOR, ".open > ul > .closed:nth-child(1) > span").click()
self.selenium.find_element(By.CSS_SELECTOR, ".open > ul > .closed:nth-child(1) > span").click()
self.selenium.find_element(By.CSS_SELECTOR, ".open > ul > .feuille:nth-child(1) > span").click()
elements = self.selenium.find_elements(By.CSS_SELECTOR, "img[alt=\'question 2644\']")
assert len(elements) > 0
elements = self.driver.find_elements(By.CSS_SELECTOR,
".feuille:nth-child(1) .seance:nth-child(1) .questionSlot:nth-child(1) img")
elements = self.selenium.find_elements(By.CSS_SELECTOR,
".feuille:nth-child(1) .seance:nth-child(1) .questionSlot:nth-child(1) img")
assert len(elements) > 0
self.driver.find_element(By.ID, "logout").click()
elements = self.driver.find_elements(By.LINK_TEXT, "Connexion")
self.selenium.find_element(By.ID, "logout").click()
elements = self.selenium.find_elements(By.LINK_TEXT, "Connexion")
assert len(elements) > 0
pytest==6.2.2
selenium==3.141.0
\ No newline at end of file
selenium==3.141.0
webdriver-manager==3.3.0
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment