mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-22 16:02:16 +00:00
Add support for running tests with geckodriver, do this on CI
This commit is contained in:
14
.github/workflows/django.yml
vendored
14
.github/workflows/django.yml
vendored
@@ -9,9 +9,13 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
browser: ['chrome', 'firefox']
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
runs-on: ubuntu-latest
|
BROWSER: ${{ matrix.browser }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: bahmutov/npm-install@v1
|
- uses: bahmutov/npm-install@v1
|
||||||
@@ -25,14 +29,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
path: ${{ env.pythonLocation }}
|
path: ${{ env.pythonLocation }}
|
||||||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}
|
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}
|
||||||
- name: Setup Chromedriver
|
|
||||||
if: \!${{ matrix.parallel }}
|
|
||||||
run: |
|
|
||||||
wget https://chromedriver.storage.googleapis.com/2.36/chromedriver_linux64.zip
|
|
||||||
unzip chromedriver_linux64.zip
|
|
||||||
export PATH=$PATH:$(pwd)
|
|
||||||
chmod +x chromedriver
|
|
||||||
export PATH=$PATH:/usr/lib/chromium-browser/
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|||||||
|
|
||||||
from RIGS import models as rigsmodels
|
from RIGS import models as rigsmodels
|
||||||
from . import pages
|
from . import pages
|
||||||
|
from envparse import env
|
||||||
|
|
||||||
|
|
||||||
def create_datetime(year, month, day, hour, min):
|
def create_datetime(year, month, day, hour, min):
|
||||||
@@ -18,20 +19,25 @@ def create_datetime(year, month, day, hour, min):
|
|||||||
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)
|
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)
|
||||||
|
|
||||||
|
|
||||||
def create_browser():
|
def create_browser(browser):
|
||||||
options = webdriver.ChromeOptions()
|
if browser == "firefox":
|
||||||
options.add_argument("--window-size=1920,1080")
|
options = webdriver.FirefoxOptions()
|
||||||
options.add_argument("--headless")
|
options.headless = True
|
||||||
if settings.CI:
|
driver = webdriver.Firefox(options=options)
|
||||||
options.add_argument("--no-sandbox")
|
else:
|
||||||
driver = webdriver.Chrome(options=options)
|
options = webdriver.ChromeOptions()
|
||||||
|
options.add_argument("--window-size=1920,1080")
|
||||||
|
options.add_argument("--headless")
|
||||||
|
if settings.CI:
|
||||||
|
options.add_argument("--no-sandbox")
|
||||||
|
driver = webdriver.Chrome(options=options)
|
||||||
return driver
|
return driver
|
||||||
|
|
||||||
|
|
||||||
class BaseTest(LiveServerTestCase):
|
class BaseTest(LiveServerTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
self.driver = create_browser()
|
self.driver = create_browser(env('BROWSER', default="chrome"))
|
||||||
self.wait = WebDriverWait(self.driver, 15)
|
self.wait = WebDriverWait(self.driver, 15)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@@ -75,4 +81,3 @@ def screenshot_failure_cls(cls):
|
|||||||
|
|
||||||
def assert_times_equal(first_time, second_time):
|
def assert_times_equal(first_time, second_time):
|
||||||
assert first_time.replace(microsecond=0) == second_time.replace(microsecond=0)
|
assert first_time.replace(microsecond=0) == second_time.replace(microsecond=0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user