We created extensions for Chrome, Firefox and Safari and we want to test our extensions with Selenium. I already created tests for Chrome and Firefox with our extension, and now I want to test our Safari extension. I found this answer about Safari but I didn't find out how to do it in Python, I checked and Selenium 2.45.0 (which we are using) doesn't have SafariOptions defined, and I didn't find out how I add an extension to the Safari tests. We use remote testing with Safari and I ran a test with Safari without our extension which passed, but I didn't find out how I create tests with our Safari extension in Python. Here are the relevant functions:
def get_chrome_options(self, file_name):
chrome_options = ChromeOptions()
chrome_options.add_extension(extension=file_name)
return chrome_options
def get_firefox_profile(self, file_name):
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.add_extension(extension=file_name)
return firefox_profile
def start_selenium_webdriver(self, caps, chrome_options=None, firefox_profile=None):
print("Starting test \"{}\" with {} {}, resolution {}.".format(caps['name'], caps['browser'], caps['browser_version'], caps['resolution']))
if (self.browser == "chrome"):
self.driver = webdriver.Chrome(chrome_options=chrome_options)
elif (self.browser == "firefox"):
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
else:
self.driver = webdriver.Remote(
command_executor='http://username:password@hub.browserstack.com:80/wd/hub',
desired_capabilities=caps
)
self.driver.implicitly_wait(time_to_wait=5)
self.driver.set_window_size(1920, 1080)
size = self.driver.get_window_size()
print("Window size: width = {}px, height = {}px.".format(size["width"], size["height"]))
I'll appreciate it if you provide answers both for local and remote testing. We want to test our extensions with Safari 7 and 8.