Skip to content

Commit ede2880

Browse files
author
Konstantinacc
committed
Updated create_webdriver function to install chrome codebender app.
When browserName is chrome, webdriver installs the codebender app.
1 parent 40d2f98 commit ede2880

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

codebender_testing/config.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def jsondump(data):
6161
_FIREFOX_EXTENSION_FNAME = 'codebender.xpi'
6262
# Chrome extension for Chrome versions < 42.
6363
_CHROME_EXTENSION_FNAME = 'codebendercc-extension.crx'
64+
# Chrome extension for Chrome versions >= 42.
65+
_CHROME_APP_FNAME = 'chrome-app-1.0.0.8.zip'
6466

6567
# Maximum version number that we can use the Chrome extension with.
6668
# For versions higher than this, we need to use the newer Codebender app.
@@ -140,24 +142,16 @@ def create_webdriver(command_executor, desired_capabilities):
140142
if browser_name == "chrome":
141143
desired_capabilities = DesiredCapabilities.CHROME.copy()
142144
desired_capabilities.update(_capabilities)
143-
144-
# NOTE: the following logic is disabled since the remote webdriver is
145-
# not properly installing the codebender extension. It is kept for
146-
# reference until we can figure out how to properly add the Chrome
147-
# extension.
148-
149-
# # Add chrome extension to capabilities
150-
# options = chrome.options.Options()
151-
# options.add_extension(os.path.join(_EXTENSIONS_DIR, _CHROME_EXTENSION_FNAME))
152-
# desired_capabilities.update(options.to_capabilities())
153-
# # Right now we only support up to v41 for this testing suite.
154-
# if "version" in desired_capabilities:
155-
# if desired_capabilities["version"] > CHROME_EXT_MAX_CHROME_VERSION:
156-
# raise ValueError("The testing suite only supports Chrome versions up to v%d, "
157-
# "but v%d was specified. Please specify a lower version "
158-
# "number." % (CHROME_EXT_MAX_CHROME_VERSION, desired_capabilities["version"]))
159-
# else:
160-
# desired_capabilities["version"] = CHROME_EXT_MAX_CHROME_VERSION
145+
if desired_capabilities["version"] > CHROME_EXT_MAX_CHROME_VERSION:
146+
# Add new chrome extension to capabilities.
147+
options = chrome.options.Options()
148+
options.add_extension(os.path.join(_EXTENSIONS_DIR, _CHROME_APP_FNAME))
149+
desired_capabilities.update(options.to_capabilities())
150+
desired_capabilities.update(_capabilities)
151+
else:
152+
raise ValueError("The testing suite only supports Chrome versions greater than v%d, "
153+
"but v%d was specified. Please specify a higher version number."
154+
% (CHROME_EXT_MAX_CHROME_VERSION, desired_capabilities["version"]))
161155

162156
elif browser_name == "firefox":
163157
desired_capabilities = DesiredCapabilities.FIREFOX.copy()

0 commit comments

Comments
 (0)