Example #1
0
 def set_preference(self, name, value):
     """
     Set a preference in about:config via user.js. Format is name, value.
     For example, set_preference("app.update.auto", "false")
     """
     FFProfile = FirefoxProfile()
     pref_dict = FFProfile.prefs
     pref_dict[name] = value
     FFProfile._update_user_preference(pref_dict)
Example #2
0
 def testCopyFromSource(self):
     dir_name = tempfile.mkdtemp()
     self._create_dummy_file(dir_name)
     profile = FirefoxProfile()
     profile.copy_profile_source(dir_name)
     profile_dir = profile.path
     dst_pref_file = open(os.path.join(profile_dir, self.DUMMY_FILE_NAME))
     content = dst_pref_file.read()
     self.assertEquals(self.DUMMY_FILE_CONTENT, content)
Example #3
0
 def testCopyFromSource(self):
     dir_name = tempfile.mkdtemp()
     self._create_dummy_file(dir_name)
     profile = FirefoxProfile()
     profile.copy_profile_source(dir_name)
     profile_dir = profile.path
     dst_pref_file = open(os.path.join(profile_dir, self.DUMMY_FILE_NAME))
     content = dst_pref_file.read()
     self.assertEquals(self.DUMMY_FILE_CONTENT, content)
Example #4
0
 def set_preference(self, name, value):
     """
     Set a preference in about:config via user.js. Format is name, value.
     For example, set_preference("app.update.auto", "false")
     """
     FFProfile = FirefoxProfile()
     pref_dict = FFProfile.prefs
     pref_dict[name] = value
     FFProfile._update_user_preference(pref_dict)
Example #5
0
def enable_selenium_specs_to_run_offline():
    prefs = FirefoxProfile._get_webdriver_prefs()
    prefs['network.manage-offline-status'] = 'false'
    @staticmethod
    def prefs_func():
        return prefs
    FirefoxProfile._get_webdriver_prefs = prefs_func
Example #6
0
def enable_selenium_specs_to_run_offline():
    prefs = FirefoxProfile._get_webdriver_prefs()
    prefs['network.manage-offline-status'] = 'false'

    @staticmethod
    def prefs_func():
        return prefs

    FirefoxProfile._get_webdriver_prefs = prefs_func
Example #7
0
    def __init__(self, profile=None, timeout=30):
        """Creates a webdriver instance.

        Args:
          profile: a FirefoxProfile object (it can also be a profile name,
                   but the support for that may be removed in future, it is
                   recommended to pass in a FirefoxProfile object)
          timeout: the amount of time to wait for extension socket
        """
        self.browser = FirefoxLauncher()
        if type(profile) == str:
            # This is to be Backward compatible because we used to take a
            # profile name
            profile = FirefoxProfile(name=profile)
        if not profile:
            profile = FirefoxProfile()
        self.browser.launch_browser(profile)
        RemoteWebDriver.__init__(self,
                                 command_executor=ExtensionConnection(timeout),
                                 browser_name='firefox',
                                 platform='ANY',
                                 version='',
                                 javascript_enabled=True)
Example #8
0
 def testNamedProfile(self):
     profile = FirefoxProfile("example")
     driver = WebDriver(profile)
     driver.get("http://localhost:%d/simpleTest.html" % WEB_SERVER_PORT)
     self.assertEquals("Hello WebDriver", driver.get_title())
     driver.quit()
Example #9
0
 def get_preferences(self):
     """View the current list of preferences set in about:config."""
     FFProfile = FirefoxProfile()
     return FFProfile.prefs