1

I am loading Firefox with an extension list so...

 ffprofile = webdriver.FirefoxProfile()
 ffprofile.add_extension(extension="ff_extensions/myextension.xpi")
 driver = webdriver.Firefox(firefox_profile=ffprofile)
 return driver

This works but the extension opens up it's install complete splash screen. Is there a way to disable these from showing or a way to close all tabs on launch?

fightstarr20
  • 11,682
  • 40
  • 154
  • 278

1 Answers1

1

One option would be to issue driver.quit() which in case of Firefox should close the tab.

Or, call CTRL/COMMAND + W shortcut to close the current tab:

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

ActionChains(driver).send_keys(Keys.CONTROL, "p").perform()  # or Keys.COMMAND on Mac

Also, depending on the extension, this kind of welcome/first-run behavior could be controlled through the firefox preferences. For example, here is how to disable it in case of AdBlock: Python Using Adblock with Selenium and Firefox Webdriver.

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195