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


Python FirefoxProfile.update_preferences方法代码示例

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


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

示例1: setUp

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import update_preferences [as 别名]
    def setUp(self):
        profile = FirefoxProfile()
        # Ignore certification
        profile.set_preference("webdriver_assume_untrusted_issuer", False)
        profile.set_preference("webdriver_accept_untrusted_certs", True)
        profile.accept_untrusted_certs = True
        
        # Set user agent
        profile.set_preference("general.useragent.override", "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A365 Safari/600.1.4")
        profile.update_preferences()
        self.driver = webdriver.Firefox(profile)

        self.base_url = "http://m.finance.yahoo.co.jp/"
        self.driver.implicitly_wait(30)
        self.accept_next_alert = True
开发者ID:ericsissy,项目名称:selenium,代码行数:17,代码来源:certification_test.py

示例2: _load_firefox_profile

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import update_preferences [as 别名]
def _load_firefox_profile():
    # create a firefox profile using the template in data/firefox_profile.js.template
    global firefox_profile_tmpdir
    if firefox_profile_tmpdir is None:
        firefox_profile_tmpdir = mkdtemp(prefix='firefox_profile_')
        # Clean up tempdir at exit
        atexit.register(rmtree, firefox_profile_tmpdir)

    template = data_path.join('firefox_profile.js.template').read()
    profile_json = Template(template).substitute(profile_dir=firefox_profile_tmpdir)
    profile_dict = json.loads(profile_json)

    profile = FirefoxProfile(firefox_profile_tmpdir)
    for pref in profile_dict.iteritems():
        profile.set_preference(*pref)
    profile.update_preferences()
    return profile
开发者ID:sshveta,项目名称:cfme_tests,代码行数:19,代码来源:browser.py

示例3: _load_firefox_profile

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import update_preferences [as 别名]
def _load_firefox_profile():
    # create a firefox profile using the template in data/firefox_profile.js.template

    # Make a new firefox profile dir if it's unset or doesn't exist for some reason
    firefox_profile_tmpdir = mkdtemp(prefix='firefox_profile_')
    log.debug("created firefox profile")
    # Clean up tempdir at exit
    atexit.register(rmtree, firefox_profile_tmpdir, ignore_errors=True)

    template = data_path.join('firefox_profile.js.template').read()
    profile_json = Template(template).substitute(profile_dir=firefox_profile_tmpdir)
    profile_dict = json.loads(profile_json)

    profile = FirefoxProfile(firefox_profile_tmpdir)
    for pref in profile_dict.items():
        profile.set_preference(*pref)
    profile.update_preferences()
    return profile
开发者ID:psav,项目名称:cfme_tests,代码行数:20,代码来源:browser.py

示例4: _load_firefox_profile

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import update_preferences [as 别名]
def _load_firefox_profile():
    # create a firefox profile using the template in data/firefox_profile.js.template
    global firefox_profile_tmpdir

    # Make a new firefox profile dir if it's unset or doesn't exist for some reason
    if firefox_profile_tmpdir is None or not os.path.exists(firefox_profile_tmpdir):
        firefox_profile_tmpdir = mkdtemp(prefix="firefox_profile_")
        # Clean up tempdir at exit
        atexit.register(rmtree, firefox_profile_tmpdir, ignore_errors=True)

    template = data_path.join("firefox_profile.js.template").read()
    profile_json = Template(template).substitute(profile_dir=firefox_profile_tmpdir)
    profile_dict = json.loads(profile_json)

    profile = FirefoxProfile(firefox_profile_tmpdir)
    for pref in profile_dict.iteritems():
        profile.set_preference(*pref)
    profile.update_preferences()
    return profile
开发者ID:anewmanRH,项目名称:cfme_tests,代码行数:21,代码来源:browser.py

示例5: FirefoxProfile

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import update_preferences [as 别名]
firefox_options.binary_location = '/Applications/Firefox.app/Contents/MacOS/firefox'
# firefox_options.headless = True

# FirefoxProfile
firefox_profile = FirefoxProfile();
firefox_profile.set_preference('browser.privatebrowsing.autostart', True)
firefox_profile.set_preference('pdfjs.disabled', True)
firefox_profile.set_preference('browser.download.folderList', 2)
firefox_profile.set_preference('browser.download.panel.shown', False)
firefox_profile.set_preference('browser.tabs.warnOnClose', False)
firefox_profile.set_preference('browser.tabs.animate', False)
firefox_profile.set_preference('browser.fullscreen.animateUp', 0)
firefox_profile.set_preference('geo.enabled', False)
firefox_profile.set_preference('browser.urlbar.suggest.searches', False)
firefox_profile.set_preference('browser.tabs.warnOnCloseOtherTabs', False)
firefox_profile.update_preferences()

# DesiredCapabilities
firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()
firefox_capabilities['marionette'] = True
firefox_capabilities['acceptInsecureCerts'] = True

# iniciar navegador
w = webdriver.Firefox(options=firefox_options, firefox_profile=firefox_profile,
                      desired_capabilities=firefox_capabilities)

# tempo de espera padrao
w.implicitly_wait(15)

w.get('https://www.uol.com.br')
开发者ID:f0r34chb3t4,项目名称:main,代码行数:32,代码来源:selenium_macos_firefox.py

示例6: create_profile

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import update_preferences [as 别名]
def create_profile(path=None, user_agent=None, accept_language=None,
                   proxy=None, proxy_type=None, no_proxy_hosts=None,
                   download_directory=None,
                   download_content_type=None):
    """
    @paramDownload_content_type: CSV string
    """

    if path is not None:
        profile = FirefoxProfile(path)
    else:
        profile = FirefoxProfile()

    # Memory and cpu optimization
    profile.set_preference('browser.sessionhistory.max_total_viewers', 0)
    #profile.set_preference('browser.cache.memory.enable', False)
    #profile.set_preference('browser.cache.offline.enable', False)
    #profile.set_preference('browser.cache.disk.enable', False)
    profile.set_preference('browser.safebrowsing.enabled', False)
    profile.set_preference('browser.shell.checkDefaultBrowser', False)
    profile.set_preference('browser.startup.page', 0)
    profile.set_preference('dom.ipc.plugins.enabled.timeoutSecs', 15)
    profile.set_preference('dom.max_script_run_time', 10)
    profile.set_preference('extensions.checkCompatibility', False)
    profile.set_preference('extensions.checkUpdateSecurity', False)
    profile.set_preference('extensions.update.autoUpdateEnabled', False)
    profile.set_preference('extensions.update.enabled', False)
    profile.set_preference('network.http.max-connections-per-server', 30)
    profile.set_preference('network.prefetch-next', False)
    profile.set_preference('plugin.default_plugin_disabled', False)
    profile.set_preference('print.postscript.enabled', False)
    profile.set_preference('toolkit.storage.synchronous', 0)
    profile.set_preference('image.animation_mode', 'none')
    profile.set_preference('images.dither', False)
    profile.set_preference('content.notify.interval', 1000000)
    profile.set_preference('content.switch.treshold', 100000)
    profile.set_preference('nglayout.initialpaint.delay', 1000000)
    profile.set_preference('network.dnscacheentries', 200)
    profile.set_preference('network.dnscacheexpiration', 600)

    if user_agent is not None:
        profile.set_preference("general.useragent.override", user_agent)

    if accept_language is not None:
        profile.set_preference('intl.accept_languages', accept_language)

    if proxy is not None:
        logging.debug('Setting up proxy %s [%s]' % (proxy, proxy_type))
        server, port = proxy.split(':')
        if proxy_type == 'socks5':
            profile.set_preference("network.proxy.socks", server)
            profile.set_preference("network.proxy.socks_port", int(port))
        elif proxy_type == 'http':
            profile.set_preference("network.proxy.http", server)
            profile.set_preference("network.proxy.http_port", int(port))
        else:
            raise Exception('Unkown proxy type: %s' % proxy_type)
        profile.set_preference("network.proxy.type", 1)

    if no_proxy_hosts is not None:
        csv = ', '.join(no_proxy_hosts)
        profile.set_preference('network.proxy.no_proxies_on',
                               'localhost, 127.0.0.1, %s' % csv)

    if download_directory is not None and download_content_type is not None:
        profile.set_preference("browser.download.folderList", 2)
        profile.set_preference("browser.download.manager.showWhenStarting", False)
        profile.set_preference("browser.download.dir", download_directory)
        profile.set_preference("browser.helperApps.neverAsk.saveToDisk",
                               download_content_type)

    profile.update_preferences()
    return profile
开发者ID:Scaurus,项目名称:grab,代码行数:75,代码来源:selenium_tools.py


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