Skip to content
Snippets Groups Projects
Verified Commit 02e70d59 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[Tests] Use SeleniumTestCase

parent 45835dba
No related branches found
No related tags found
No related merge requests found
......@@ -2,31 +2,24 @@ import os
import pytest
from django.test import LiveServerTestCase
from django.test.selenium import SeleniumTestCase
webdriver = pytest.importorskip('selenium.webdriver')
if not os.environ.get('TEST_SELENIUM_HUB', None):
pytest.skip('Selenium hub not defined.', allow_module_level=True)
class SeleniumTests(LiveServerTestCase):
__test__ = False
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.selenium.set_window_size(1920, 1080)
cls.selenium.implicitly_wait(10)
@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super().tearDownClass()
class SeleniumTests(SeleniumTestCase):
external_host = os.environ.get('TEST_LISTEN_ADDRESS', '127.0.0.1')
browsers = ['chrome', 'firefox']
selenium_hub = 'http://%s/wd/hub' % os.environ.get('TEST_SELENIUM_HUB', '127.0.0.1:4444')
@classmethod
def _screenshot(cls, filename):
screenshot_path = os.environ.get('TEST_SCREENSHOT_PATH', None)
if screenshot_path:
return cls.selenium.save_screenshot(os.path.join(screenshot_path, filename))
os.makedirs(os.path.join(screenshot_path, cls.browser), exist_ok=True)
return cls.selenium.save_screenshot(os.path.join(screenshot_path, cls.browser, filename))
else:
return False
......@@ -35,31 +28,3 @@ class SeleniumTests(LiveServerTestCase):
self.selenium.get(self.live_server_url + '/')
assert 'BiscuIT' in self.selenium.title
self._screenshot('index.png')
class SeleniumTestsChromium(SeleniumTests):
__test__ = True
@classmethod
def setUpClass(cls):
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-extensions')
options.add_argument('--disable-gpu')
options.add_argument("--disable-impl-side-painting")
options.add_argument("--disable-setuid-sandbox")
options.add_argument("--disable-seccomp-filter-sandbox")
options.add_argument("--disable-breakpad")
options.add_argument("--disable-client-side-phishing-detection")
options.add_argument("--disable-cast")
options.add_argument("--disable-cast-streaming-hw-encoding")
options.add_argument("--disable-cloud-import")
options.add_argument("--disable-popup-blocking")
options.add_argument("--ignore-certificate-errors")
options.add_argument("--disable-session-crashed-bubble")
cls.selenium = webdriver.Chrome(options=options)
super().setUpClass()
......@@ -9,6 +9,8 @@ skip_install = true
commands = pytest --pylama --cov=biscuit biscuit/core/
setenv =
TEST_SCREENSHOT_PATH = {env:TEST_SCREENSHOT_PATH:}
TEST_SELENIUM_HUB = {env:TEST_SELENIUM_HUB:}
TEST_LISTEN_ADDRESS = {env:TEST_LISTEN_ADDRESS:127.0.0.1}
[pylama]
linters = pycodestyle,pyflakes,radon
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment