当前位置: 首页>>代码示例>>Python>>正文


Python FirefoxProfile.update_preferences方法代码示例

本文整理汇总了Python中selenium.webdriver.FirefoxProfile.update_preferences方法的典型用法代码示例。如果您正苦于以下问题:Python FirefoxProfile.update_preferences方法的具体用法?Python FirefoxProfile.update_preferences怎么用?Python FirefoxProfile.update_preferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.FirefoxProfile的用法示例。


在下文中一共展示了FirefoxProfile.update_preferences方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_download_dir_profile_for_firefox

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
    def create_download_dir_profile_for_firefox(path_to_download, mime_types_file=None, *extensions_files):
        """
        Example use
        | ${profile} | Create Download Dir Profile For Firefox | Artifacts | Resources/mimeTypes.rdf | Resources/webdriver_element_locator-2.0-fx.xpi | Resources/selenium_ide-2.9.1-fx.xpi |
        | Open Browser Extension | https://support.spatialkey.com/spatialkey-sample-csv-data/ | ff_profile_dir=${profile} |
        | Click Element | //a[contains(@href,'sample.csv.zip')]  |
        """
        path_to_download_check = validate_create_artifacts_dir(path_to_download)

        fp = FirefoxProfile()
        fp.set_preference("browser.download.folderList", 2)
        fp.set_preference("browser.download.manager.showWhenStarting", False)
        fp.set_preference("browser.download.manager.alertOnEXEOpen", False)
        fp.set_preference("browser.download.dir", path_to_download_check)
        fp.set_preference("xpinstall.signatures.required", False)
        fp.set_preference("browser.helperApps.alwaysAsk.force", False)
        fp.set_preference("browser.helperApps.neverAsk.saveToDisk",
            "application/msword;application/csv;text/csv;image/png;image/jpeg;application/pdf;text/html;text/plain;application/octet-stream")
        fp.set_preference("pdfjs.disabled", True)
        fp.update_preferences()
        for single_extension in extensions_files:
            fp.add_extension(single_extension)
        if mime_types_file is not None:
            from shutil import copy2
            copy2(os.path.normpath(mime_types_file), fp.profile_dir)
        logger.info("Firefox Profile Created in dir '" + fp.profile_dir + "'")
        return fp.profile_dir
开发者ID:jsonpanganiban,项目名称:robotframework-MarcinKoperski,代码行数:29,代码来源:selenium_extentions_keywords.py

示例2: makeProfile

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
  def makeProfile(self, config):
    
    profile = FirefoxProfile()

    # Disable Firefox auto update
    profile.set_preference("app.update.enabled", False)

    try:
      if config["fire_bug"]:
        profile.add_extension(FIREBUG_EXTENSION)
    
        domain = "extensions.firebug."
        # Set default Firebug preferences
       
        # Avoid Firebug start page
        profile.set_preference(domain + "currentVersion", "2.0.6")
        # Activate everything
        profile.set_preference(domain + "allPagesActivation", "on")
        profile.set_preference(domain + "defaultPanelName", "net")
        # Enable Firebug on all sites
        profile.set_preference(domain + "net.enableSites", True)
       
        self.logger.info("Firebug profile settings enabled")

    except KeyError:
      self.logger.warning("Firebug profile settings failed")
      pass 


    try:
      if config["net_export"]:
        profile.add_extension(NETEXPORT_EXTENSION)

        # Set default NetExport preferences
        self.har_output = config["net_export_output"]
        #self.logger.info("Output HAR directory: {0}".format(self.har_output))
        profile.set_preference(domain + "netexport.defaultLogDir", self.har_output)
        profile.set_preference(domain + "netexport.autoExportToFile", True)
        profile.set_preference(domain + "netexport.alwaysEnableAutoExport", True)
        # Do not show preview output
        profile.set_preference(domain + "netexport.showPreview", True)
        profile.set_preference(domain + "netexport.pageLoadedTimeout", 3000)
        # Log dir
        self.logger.info("NetExport profile settings enabled.")

        # Har ID to check file exists
        self.har_id = int((datetime.datetime.now()-datetime.datetime(1970,1,1)).total_seconds()*1000000)
        self.url += "/?{0}".format(self.har_id)
        #print self.url

    except KeyError:
      self.logger.warning("NetExport profile settings failed")
      pass

    profile.update_preferences()
    return profile
开发者ID:jonnybazookatone,项目名称:bumblebee_benchmark,代码行数:58,代码来源:benchmark.py

示例3: test_that_we_can_accept_a_profile

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
def test_that_we_can_accept_a_profile(capabilities, webserver):
    profile1 = FirefoxProfile()
    profile1.set_preference("browser.startup.homepage_override.mstone", "")
    profile1.set_preference("startup.homepage_welcome_url", webserver.where_is('simpleTest.html'))
    profile1.update_preferences()

    profile2 = FirefoxProfile(profile1.path)
    driver = Firefox(
        capabilities=capabilities,
        firefox_profile=profile2)
    title = driver.title
    driver.quit()
    assert "Hello WebDriver" == title
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:15,代码来源:ff_profile_tests.py

示例4: firefox_profile

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
def firefox_profile(request):
    profile = FirefoxProfile(request.config.getoption('firefox_profile'))
    for preference in request.config.getoption('firefox_preferences'):
        name, value = preference
        if value.isdigit():
            # handle integer preferences
            value = int(value)
        elif value.lower() in ['true', 'false']:
            # handle boolean preferences
            value = value.lower() == 'true'
        profile.set_preference(name, value)
    profile.update_preferences()
    for extension in request.config.getoption('firefox_extensions'):
        profile.add_extension(extension)
    return profile
开发者ID:ClinicalGraphics,项目名称:pytest-selenium,代码行数:17,代码来源:firefox.py

示例5: test_that_unicode_prefs_are_written_in_the_correct_format

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
def test_that_unicode_prefs_are_written_in_the_correct_format():
    profile = FirefoxProfile()
    profile.set_preference('sample.preference.2', unicode('hi there'))
    profile.update_preferences()

    assert 'hi there' == profile.default_preferences["sample.preference.2"]

    encoded = profile.encoded
    decoded = base64.b64decode(encoded)
    with BytesIO(decoded) as fp:
        zip = zipfile.ZipFile(fp, "r")
        for entry in zip.namelist():
            if entry.endswith('user.js'):
                user_js = zip.read(entry)
                for line in user_js.splitlines():
                    if line.startswith(b'user_pref("sample.preference.2",'):
                        assert line.endswith(b'hi there");')
            # there should be only one user.js
            break
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:21,代码来源:ff_profile_tests.py

示例6: __init__

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
 def __init__(self,test,browser_name,url,test_data=None):
     super(FrameworkTests,self).__init__(test)
     self.test=test
     self.browser_name=browser_name
     self.url=url
     self.driver=None
     if self.browser_name=='firefox':
         ffp = FirefoxProfile()
         ffp.update_preferences()
         self.driver = Firefox(firefox_profile=ffp)
     elif self.browser_name=='chrome':
         chromedriver = load_browser_driver("chromedriver")
         os.environ["webdriver.chrome.driver"] = chromedriver
         self.driver=Chrome(chromedriver)
     elif self.browser_name=='ie':
         iedriver = load_browser_driver("IEDriverServer")
         os.environ["webdriver.ie.driver"] = iedriver
         self.driver=Ie(iedriver)
     self.verification = []
     self.verification.append("Test %s on browser %s" %(self.test,self.browser_name))
     self.test_data=test_data
     self.errors=[]
开发者ID:ionitadaniel19,项目名称:testframeworksevolution,代码行数:24,代码来源:utests.py

示例7: firefox_profile

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
def firefox_profile(pytestconfig):
    profile = None
    if pytestconfig.getoption('firefox_profile'):
        profile = FirefoxProfile(pytestconfig.getoption('firefox_profile'))
        warnings.warn(
            '--firefox-profile has been deprecated and will be removed in '
            'a future release. Please use the firefox_options fixture to '
            'set a profile path or FirefoxProfile object using '
            'firefox_options.profile.', DeprecationWarning)
    if pytestconfig.getoption('firefox_preferences'):
        profile = profile or FirefoxProfile()
        warnings.warn(
            '--firefox-preference has been deprecated and will be removed in '
            'a future release. Please use the firefox_options fixture to set '
            'preferences using firefox_options.set_preference. If you are '
            'using Firefox 47 or earlier then you will need to create a '
            'FirefoxProfile object with preferences and set this using '
            'firefox_options.profile.', DeprecationWarning)
        for preference in pytestconfig.getoption('firefox_preferences'):
            name, value = preference
            if value.isdigit():
                # handle integer preferences
                value = int(value)
            elif value.lower() in ['true', 'false']:
                # handle boolean preferences
                value = value.lower() == 'true'
            profile.set_preference(name, value)
        profile.update_preferences()
    if pytestconfig.getoption('firefox_extensions'):
        profile = profile or FirefoxProfile()
        warnings.warn(
            '--firefox-extensions has been deprecated and will be removed in '
            'a future release. Please use the firefox_options fixture to '
            'create a FirefoxProfile object with extensions and set this '
            'using firefox_options.profile.', DeprecationWarning)
        for extension in pytestconfig.getoption('firefox_extensions'):
            profile.add_extension(extension)
    return profile
开发者ID:davehunt,项目名称:pytest-selenium,代码行数:40,代码来源:firefox.py

示例8: test_that_boolean_prefs_are_written_in_the_correct_format

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
def test_that_boolean_prefs_are_written_in_the_correct_format():
    profile = FirefoxProfile()
    profile.set_preference("sample.bool.preference", True)
    profile.update_preferences()
    assert profile.default_preferences["sample.bool.preference"] is True
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:7,代码来源:ff_profile_tests.py

示例9: test_that_integer_prefs_are_written_in_the_correct_format

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
def test_that_integer_prefs_are_written_in_the_correct_format():
    profile = FirefoxProfile()
    profile.set_preference("sample.int.preference", 12345)
    profile.update_preferences()
    assert 12345 == profile.default_preferences["sample.int.preference"]
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:7,代码来源:ff_profile_tests.py

示例10: profile

# 需要导入模块: from selenium.webdriver import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.FirefoxProfile import update_preferences [as 别名]
def profile():
    profile = FirefoxProfile()
    profile.set_preference('browser.startup.homepage_override.mstone', '')
    profile.set_preference('startup.homepage_welcome_url', 'about:')
    profile.update_preferences()
    return profile
开发者ID:Jarob22,项目名称:selenium,代码行数:8,代码来源:mn_profile_tests.py


注:本文中的selenium.webdriver.FirefoxProfile.update_preferences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。