I use selenium python. My code work success, the extension was added. But when I close the code, open the Firefox Profile which added extension by manually then the extension isn't installed. My code
from selenium import webdriver from selenium.webdriver.common.by import By import time
try:
path = "My_profile_PATH"
fp = webdriver.FirefoxProfile(path)
driver = webdriver.Firefox(firefox_profile=fp)
# path to your downloaded Firefox addon extension XPI file
extension_path = "MY_extension_PATH"
# using webdriver's install_addon API to install the downloaded Firefox extension
driver.install_addon(extension_path, temporary=True)
# Opening the Firefox support page to verify that addon is installed
driver.get("about:support")
# xpath to the section on the support page that lists installed extension
addons = driver.find_element(By.XPATH,'//*[contains(text(),"Add-ons") and not(contains(text(),"with"))]')
# scrolling to the section on the support page that lists installed extension
driver.execute_script("arguments[0].scrollIntoView();", addons)
# introducing program halt time to view things, ideally remove this when performing test automation in the cloud using LambdaTest
print("Success. Yayy!!")
time.sleep(20)
except Exception as E:
print(E)
finally:
# exiting the fired Mozilla Firefox selenium webdriver instance
driver.quit()
# End Of Script