Skip to content

Commit bbd663c

Browse files
author
Brandon Duffany
committed
Add firefox extension support
1 parent 8ffa7eb commit bbd663c

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

codebender_testing/config.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1+
import os
2+
13
from selenium import webdriver
24

35

46
# URL of the site to be used for testing
57
BASE_URL = "http://localhost"
68

7-
# Selenium Webdrivers to be used for selenium tests
9+
10+
_EXTENSIONS_DIR = 'extensions'
11+
_FIREFOX_EXTENSION_FNAME = 'codebender.xpi'
12+
13+
# Set up Selenium Webdrivers to be used for selenium tests
14+
15+
def _get_firefox_profile():
16+
"""Returns the Firefox profile to be used for the FF webdriver.
17+
Specifically, we're equipping the webdriver with the Codebender
18+
extension.
19+
"""
20+
firefox_profile = webdriver.FirefoxProfile()
21+
firefox_profile.add_extension(
22+
extension=os.path.join(_EXTENSIONS_DIR, _FIREFOX_EXTENSION_FNAME)
23+
)
24+
return firefox_profile
25+
826
WEBDRIVERS = {
9-
"firefox": webdriver.Firefox
27+
"firefox": webdriver.Firefox(firefox_profile=_get_firefox_profile())
1028
}
1129

1230
# Credentials to use when logging into the site via selenium

extensions/codebender.xpi

4.44 MB
Binary file not shown.

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def webdriver(request):
99
and registers a finalizer to close the browser once the session is
1010
complete. The entire test session is repeated once per driver.
1111
"""
12-
driver = WEBDRIVERS[request.param]()
12+
driver = WEBDRIVERS[request.param]
1313
request.addfinalizer(lambda: driver.quit())
1414
return driver
1515

0 commit comments

Comments
 (0)