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


Python FirefoxProfile.set_preference方法代码示例

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


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

示例1: webdriver_class

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
        def webdriver_class():
            profile = FirefoxProfile()

            # Make sure Firefox WebDriver addon works, even if it could not be verified
            profile.set_preference('xpinstall.signatures.required', False)
            webdriver = Firefox(profile)
            return webdriver
开发者ID:Ins1ne,项目名称:Selenium-Requests,代码行数:9,代码来源:test_seleniumrequests.py

示例2: setup_browser

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def setup_browser():
    world.browser = None
    browser = getattr(settings, 'BROWSER', None)
    if browser is None:
        raise Exception('Please configure a browser in settings_test.py')
    elif browser == 'Firefox':
        ff_profile = FirefoxProfile()
        ff_profile.set_preference("webdriver_enable_native_events", False)
        world.browser = webdriver.Firefox(ff_profile)
    elif browser == 'Chrome':
        world.browser = webdriver.Chrome()
    elif browser == "Headless":
        world.browser = webdriver.PhantomJS(
            desired_capabilities={'handlesAlerts': True})

    world.client = client.Client()
    world.using_selenium = False

    world.browser.set_window_position(0, 0)
    world.browser.set_window_size(1024, 768)

    # Wait implicitly for 2 seconds
    world.browser.implicitly_wait(2)

    # stash
    world.memory = {}
开发者ID:6C1,项目名称:mediathread,代码行数:28,代码来源:terrain.py

示例3: getDriver

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def getDriver(httpProxy = '', type='Firefox'):
  if type == 'Firefox':
    proxy = Proxy({
      'proxyType': ProxyType.MANUAL,
      'httpProxy': httpProxy,
      'ftpProxy': httpProxy,
      'sslProxy': httpProxy,
      'noProxy': '' # set this value as desired
      })
    firefox_profile = FirefoxProfile()
    #firefox_profile.add_extension("firefox_extensions/adblock_plus-2.5.1-sm+tb+an+fx.xpi")
    firefox_profile.add_extension("firefox_extensions/webdriver_element_locator-1.rev312-fx.xpi")
    firefox_profile.set_preference("browser.download.folderList",2)
    firefox_profile.set_preference("webdriver.load.strategy", "unstable")
    #driver = webdriver.Firefox(firefox_profile = firefox_profile, proxy=proxy, firefox_binary=FirefoxBinary('/usr/bin/firefox'))
    #driver = webdriver.Firefox(firefox_profile = firefox_profile, proxy=proxy, firefox_binary=FirefoxBinary("/cygdrive/c/Program\ Files\ (x86)/Mozilla\ Firefox/firefox.exe"))
    driver = webdriver.Firefox(firefox_profile = firefox_profile, proxy=proxy)
  elif type == 'PhantomJS':  #  PhantomJS
    service_args = [
    '--proxy='+httpProxy,
    '--proxy-type=http',
    ]
    webdriver.DesiredCapabilities.PHANTOMJS['phantomjs.page.customHeaders.Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
    webdriver.DesiredCapabilities.PHANTOMJS['phantomjs.page.customHeaders.User-Agent'] = 'Mozilla/5.0 (X11; Windows x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36'
    driver = webdriver.PhantomJS(executable_path='windows/phantomjs.exe', service_args=service_args)
  else: # Chrome
    chrome_options = webdriver.ChromeOptions()
    #chrome_options.add_extension('firefox_extensions/adblockplus_1_7_4.crx')
    chrome_options.add_argument('--proxy-server=%s' % httpProxy)
    driver = webdriver.Chrome(executable_path='windows/chromedriver.exe', chrome_options=chrome_options)
  return driver
开发者ID:FashtimeDotCom,项目名称:shangxueba,代码行数:33,代码来源:fetch.py

示例4: setup_slow_browser

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def setup_slow_browser():
    # Start the browser
    profile = FirefoxProfile()
    # When inserting many lines of text the Javascript process takes ages
    profile.set_preference('dom.max_script_run_time', 10*60)
    profile.set_preference('dom.max_chrome_script_run_time', 10*60)
    world.slow_browser = webdriver.Firefox(firefox_profile=profile)
开发者ID:cburgmer,项目名称:deniz,代码行数:9,代码来源:validate-steps.py

示例5: setup_browser

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def setup_browser():
    world.browser = None
    browser = getattr(settings, 'BROWSER', None)
    if browser is None:
        raise Exception('Please configure a browser in settings_test.py')
    elif browser == 'Firefox':
        ff_profile = FirefoxProfile()
        ff_profile.set_preference("webdriver_enable_native_events", False)
        world.browser = webdriver.Firefox(ff_profile)
    elif browser == 'Chrome':
        world.browser = webdriver.Chrome()
    elif browser == "Headless":
        world.browser = webdriver.PhantomJS(
            desired_capabilities={'handlesAlerts': True})
        cmd = "window.moveTo(0, 1); window.resizeTo(%s, %s);" % (1024, 768)
        world.browser.execute_script(cmd)

    world.client = client.Client()
    world.using_selenium = False

    # Make the browser size at least 1024x768
    world.browser.execute_script("window.moveTo(0, 1); "
                                 "window.resizeTo(1024, 768);")

    # Wait implicitly for 2 seconds
    world.browser.implicitly_wait(5)

    # stash
    world.memory = {}
开发者ID:appsembler,项目名称:mediathread-openshift-quickstart-backup,代码行数:31,代码来源:terrain.py

示例6: disableImages

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
	def disableImages(self):
		fireFoxProfile = FirefoxProfile()	# Nuovo profilo di FireFox #(anonimo credo, ma non importa, a meno che non voglia crearne uno, salvarlo e caricarlo da qua) 
		
		fireFoxProfile.set_preference('permissions.default.stylesheet', 2)						# no CSS
		fireFoxProfile.set_preference('permissions.default.image', 2)							# no Image
		# fireFoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so','false')	# no Flash 
		return fireFoxProfile	# restituico il profilo appena creato
开发者ID:Stravanni,项目名称:Gplay-Scraper,代码行数:9,代码来源:__init__.py

示例7: setup_browser

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def setup_browser():
    firefox_profile = FirefoxProfile()
    # Reduce bandwidth consumption and increase speed by disabling images, Flash
    firefox_profile.set_preference('permissions.default.image', 2)
    firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so',
                                  'false')
    return webdriver.Firefox(firefox_profile)
开发者ID:mab13,项目名称:GooglePrivacyEnhancer,代码行数:9,代码来源:script.py

示例8: get_webdriver

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def get_webdriver():
    profile = FirefoxProfile()
    profile.set_preference("browser.download.panel.shown", False)
    profile.set_preference("browser.helperApps.neverAsk.openFile","text/csv,application/vnd.ms-excel")
    profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel")
    profile.set_preference("browser.download.folderList", 2);
    profile.set_preference("browser.download.dir", "c:\\firefox_downloads\\")
    return webdriver.Firefox(firefox_profile=profile)
开发者ID:tbridges42,项目名称:MyVote_Notifications,代码行数:10,代码来源:scraper.py

示例9: StartBrowser

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def StartBrowser(browserChoice):
    if browserChoice == 1:
        print '\nLaunching Chrome'
        browser = webdriver.Chrome()

    if browserChoice == 2:
        print '\nLaunching Firefox/Iceweasel'
        browser = webdriver.Firefox()

    if browserChoice == 3:
        print '\nLaunching Firefox/Iceweasel (light)'
        from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
        firefoxLightProfile = FirefoxProfile()
        firefoxLightProfile.set_preference('permissions.default.stylesheet', 2) # Disable CSS
        firefoxLightProfile.set_preference('permissions.default.image', 2) # Disable images
        firefoxLightProfile.set_preference('javascript.enabled', False) # Disable javascript
        firefoxLightProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', False) # Disable Flash
        firefoxLightProfile.set_preference('browser.chrome.toolbar_style', 0) # Display toolbar buttons with icons only, no text
        browser = webdriver.Firefox(firefoxLightProfile)

    if browserChoice == 4:
        print '\nLaunching PhantomJS'
        browser = webdriver.PhantomJS()

    if browserChoice == 5:
        print '\nLaunching PhantomJS (light)'
        browser = webdriver.PhantomJS()
        browser.desired_capabilities['userAgent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36'
        browser.desired_capabilities['javascriptEnabled'] = False
        browser.desired_capabilities['loadImages'] = False
        browser.desired_capabilities['webSecurityEnabled'] = False

    # Open, load and close the 'config' file
    with open('config', 'r') as configFile:
        config = [line.strip() for line in configFile]
    configFile.close()

    # Sign in
    browser.get('https://linkedin.com/uas/login')
    emailElement = browser.find_element_by_id('session_key-login')
    emailElement.send_keys(config[0])
    passElement = browser.find_element_by_id('session_password-login')
    passElement.send_keys(config[1])
    passElement.submit()

    print 'Signing in...'
    time.sleep(3)

    soup = BeautifulSoup(browser.page_source)
    if soup.find('div', {'class':'alert error'}):
        print 'Error! Please verify your username and password.'
        browser.quit()
    elif browser.title == '403: Forbidden':
        print 'LinkedIn is momentarily unavailable. Please wait a moment, then try again.'
        browser.quit()
    else:
        print 'Success!\n'
        LInBot(browser)
开发者ID:Savemech,项目名称:LInBot,代码行数:60,代码来源:LInBot.py

示例10: get_driver

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
    def get_driver(self):
        from selenium.webdriver import Firefox as FirefoxWebDriver
        from selenium.webdriver import Chrome as ChromeDriver
        from selenium.webdriver import Remote as RemoteDriver

        # Lazilly gets the driver one time cant call in begin since ssh tunnel
        # may not be created
        if self._driver:
            return self._driver

        if self._driver_type == 'firefox':
            from selenium.webdriver.firefox.firefox_profile import FirefoxProfile  # noqa
            fp = FirefoxProfile()

            for override in self._ff_profile_overrides:
                pref, value = override.split('=')
                fp.set_preference(pref, literal_eval(value))

            self._profile = fp

            if self._firefox_binary is None:
                self._driver = FirefoxWebDriver(firefox_profile=self._profile)
            else:
                from selenium.webdriver.firefox.firefox_binary import FirefoxBinary  # noqa
                binary = FirefoxBinary(self._firefox_binary)
                self._driver = FirefoxWebDriver(
                    firefox_profile=self._profile,
                    firefox_binary=binary
                )
        elif self._driver_type == 'chrome':
            self._driver = ChromeDriver()
        else:
            timeout = 60
            step = 1
            current = 0
            while current < timeout:
                try:
                    self._driver = RemoteDriver(
                        'http://%s:%s/wd/hub' % (
                            self._remote_server_address,
                            self._selenium_port,
                        ),
                        self._driver_type,
                        'WINDOWS',
                    )
                    break
                except URLError:
                    time.sleep(step)
                    current += step
                except BadStatusLine:
                    self._driver = None
                    break
            if current >= timeout:
                raise URLError('timeout')

        monkey_patch_methods(self._driver)
        return self._driver
开发者ID:nosedjango,项目名称:nosedjango,代码行数:59,代码来源:selenium_plugin.py

示例11: setup_browser

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def setup_browser():
    ff_profile = FirefoxProfile()
    ff_profile.set_preference("webdriver_enable_native_events", False)
    world.firefox = webdriver.Firefox(ff_profile)
    world.client = client.Client()
    world.using_selenium = False

    # Make the browser size at least 1024x768
    world.firefox.execute_script("window.moveTo(0, 1); window.resizeTo(1024, 768);")
开发者ID:tomaszzielinski,项目名称:mediathread,代码行数:11,代码来源:terrain.py

示例12: setUpClass

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
    def setUpClass(cls):
        from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
        profile = FirefoxProfile()
        profile.set_preference('geo.prompt.testing', True)
        profile.set_preference('geo.prompt.testing.allow', True)
        cls.browser = webdriver.Firefox(profile)

        cls.browser.implicitly_wait(10)
        super(RegistrationTests, cls).setUpClass()
开发者ID:Munk801,项目名称:book3-exercises,代码行数:11,代码来源:testPage.py

示例13: setup_browser

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def setup_browser(variables):
    world.using_selenium = False
    if skip_selenium():
        world.browser = None
        world.skipping = False
    else:
        ff_profile = FirefoxProfile()
        ff_profile.set_preference("webdriver_enable_native_events", False)
        world.firefox = webdriver.Firefox(ff_profile)
        world.using_selenium = False
    world.client = client.Client()
开发者ID:nikolas,项目名称:plexus,代码行数:13,代码来源:terrain.py

示例14: _setup_browser_profile

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
    def _setup_browser_profile(self):
        fp = FirefoxProfile()

        fp.set_preference("browser.download.folderList", 2)
        fp.set_preference("browser.download.manager.showWhenStarting", False)
        fp.set_preference("browser.download.dir", self.DOWNLOAD_DIR + '/')
        fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/force-download")

        if self._debug:
            fp.set_preference("webdriver.log.file", "/tmp/firefox_console")

        return fp
开发者ID:jaunis,项目名称:xivo-acceptance,代码行数:14,代码来源:xivobrowser.py

示例15: disableImages

# 需要导入模块: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile.FirefoxProfile import set_preference [as 别名]
def disableImages(self):
    ## get the Firefox profile object
    firefoxProfile = FirefoxProfile()
    ## Disable CSS
    #firefoxProfile.set_preference('permissions.default.stylesheet', 2)
    ## Disable images
    firefoxProfile.set_preference('permissions.default.image', 2)
    ## Disable Flash
    firefoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so',
                                  'false')
    ## Set the modified profile while creating the browser object 
    self.browserHandle = webdriver.Firefox(firefoxProfile)
开发者ID:jzhang0228,项目名称:coin_registeration,代码行数:14,代码来源:tmp.py


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