Skip to content

Commit

Permalink
Merge pull request #74 from OpenDataServices/bc/install-selenium
Browse files Browse the repository at this point in the history
set up selenium
  • Loading branch information
BibianaC committed Mar 10, 2021
2 parents b4f876d + e0b9c0b commit 3912b97
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
8 changes: 7 additions & 1 deletion requirements.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ flattentool==0.15.3
# via libcove
idna==2.10
# via requests
importlib-metadata==1.7.0
# via
# django-bootstrap3
# jsonschema
jdcal==1.4.1
# via openpyxl
json-merge-patch==0.2
Expand Down Expand Up @@ -137,7 +141,9 @@ xmltodict==0.12.0
# flattentool
# libcoveweb
zipp==1.2.0
# via libcoveweb
# via
# importlib-metadata
# libcoveweb

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r requirements.in
black
flake8
selenium
12 changes: 11 additions & 1 deletion requirements_dev.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ flattentool==0.15.3
# via libcove
idna==2.10
# via requests
importlib-metadata==1.7.0
# via
# django-bootstrap3
# flake8
# jsonschema
jdcal==1.4.1
# via openpyxl
json-merge-patch==0.2
Expand Down Expand Up @@ -133,6 +138,8 @@ rq==1.7.0
# via django-rq
schema==0.7.4
# via flattentool
selenium==3.141.0
# via -r requirements_dev.in
sentry-sdk==0.20.3
# via libcoveweb
six==1.15.0
Expand All @@ -156,13 +163,16 @@ typing-extensions==3.7.4.3
urllib3==1.26.3
# via
# requests
# selenium
# sentry-sdk
xmltodict==0.12.0
# via
# flattentool
# libcoveweb
zipp==1.2.0
# via libcoveweb
# via
# importlib-metadata
# libcoveweb

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
40 changes: 40 additions & 0 deletions standards_lab/ui/tests_browser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test import override_settings
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


@override_settings(ROOT_PROJECTS_DIR="/tmp/standards-lab-test")
class BrowserTests(StaticLiveServerTestCase):
""" Browser test using latest Chrome/Chromium stable"""

def __init__(self, *args, **kwargs):
os.makedirs("/tmp/standards-lab-test", exist_ok=True)
super(BrowserTests, self).__init__(*args, **kwargs)

def setUp(self, *args, **kwargs):
capabilities = DesiredCapabilities.CHROME
capabilities["loggingPrefs"] = {"browser": "ALL"}

chrome_options = Options()
chrome_options.add_argument("--headless")

self.driver = webdriver.Chrome(
service_args=["--verbose", "--log-path=selenium.log"],
desired_capabilities=capabilities,
chrome_options=chrome_options,
)
self.driver.set_page_load_timeout(15)

def tearDown(self):
self.driver.quit()

def get(self, url):
self.driver.get("%s%s" % (self.live_server_url, url))

def test_page_loads(self):
self.get("/")

self.assertIn("Welcome to Open Standards Lab", self.driver.page_source)

0 comments on commit 3912b97

Please sign in to comment.