Skip to content

Commit 7ca6b91

Browse files
committed
Add the ability to install a Firefox add-on at runtime
1 parent caec440 commit 7ca6b91

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

help_docs/method_summary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ self.wait_for_angularjs(timeout=None)
208208
self.sleep(seconds)
209209
# Duplicates: self.wait(seconds)
210210

211+
self.install_addon(xpi_file)
212+
211213
self.activate_design_mode()
212214

213215
self.deactivate_design_mode()

seleniumbase/fixtures/base_case.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,18 @@ def sleep(self, seconds):
21842184
break
21852185
time.sleep(0.2)
21862186

2187+
def install_addon(self, xpi_file):
2188+
""" Installs a Firefox add-on instantly at run-time.
2189+
@Params
2190+
xpi_file - A file archive in .xpi format. """
2191+
if self.browser != "firefox":
2192+
raise Exception(
2193+
"install_addon(xpi_file) is for Firefox ONLY!\n"
2194+
"To load a Chrome extension, use the comamnd-line:\n"
2195+
"--extension_zip=CRX_FILE OR --extension_dir=DIR")
2196+
xpi_path = os.path.abspath(xpi_file)
2197+
self.driver.install_addon(xpi_path, temporary=True)
2198+
21872199
def activate_design_mode(self):
21882200
# Activate Chrome's Design Mode, which lets you edit a site directly.
21892201
# See: https://twitter.com/sulco/status/1177559150563344384

0 commit comments

Comments
 (0)