Skip to content

Commit 9e5523d

Browse files
author
Brandon Duffany
committed
Add testing utils
Adds some functionality to replicate tests for each desired web browser.
1 parent b9ef886 commit 9e5523d

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

codebender_testing/__init__.py

Whitespace-only changes.

codebender_testing/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from selenium import webdriver
2+
3+
4+
WEBDRIVERS = {
5+
"firefox": webdriver.Firefox,
6+
"chrome": webdriver.Chrome
7+
}

codebender_testing/utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
3+
from selenium import webdriver
4+
import pytest
5+
6+
from codebender_testing.config import WEBDRIVERS
7+
8+
9+
class SeleniumTestCase(object):
10+
"""Base class for all Selenium tests."""
11+
12+
@classmethod
13+
@pytest.fixture(scope="class", autouse=True, params=WEBDRIVERS.keys())
14+
def setup(self, request):
15+
"""Sets up attributes that should be accessible to all test cases."""
16+
17+
# We repeat each test for each webdriver configuration
18+
webdriver_cls = WEBDRIVERS[request.param]
19+
self.driver = webdriver_cls()
20+

tests/home/test_home.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from selenium import webdriver
1+
from codebender_testing.utils import SeleniumTestCase
22

3-
class TestHome:
43

5-
driver = webdriver.Firefox()
4+
class TestHome(SeleniumTestCase):
65

76
def test_navigate_home(self):
87
self.driver.get("http://localhost")

0 commit comments

Comments
 (0)