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


Python webdriver.FirefoxProfile类代码示例

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


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

示例1: test_autodetect_proxy_is_set_in_profile

def test_autodetect_proxy_is_set_in_profile():
    profile = FirefoxProfile()
    proxy = Proxy()
    proxy.auto_detect = True

    profile.set_proxy(proxy)
    assert profile.default_preferences["network.proxy.type"] == ProxyType.AUTODETECT['ff_value']
开发者ID:Allariya,项目名称:selenium,代码行数:7,代码来源:ff_profile_tests.py

示例2: start

    def start(cls, url, driver=""):
        if cls.mode == "FireFox":
            default_profile = {
                'browser.usedOnWindows10': False,
                'browser.usedOnWindows10.introURL': 'https://www.google.com/',
                'startup.homepage_welcome_url.additional': 'about:blank',
                'browser.startup.homepage_override.mstone': 'ignore',
            }
            profile = FirefoxProfile()
            for name, value in default_profile.items():
                profile.set_preference(name, value)
            cls.driver = webdriver.Firefox(profile)

        elif cls.mode == "Chrome":
            try:
                if driver != "":
                    chromedriver = driver
                    L.info(chromedriver)
                    os.environ["webdriver.chrome.driver"] = chromedriver
                    cls.driver = webdriver.Chrome(chromedriver)
                else:
                    cls.driver = webdriver.Chrome()
            except Exception as e:
                L.warning(str(e))
                raise SeleniumError(
                    "Can't find Selenium Driver Mode. %s" % cls.mode)
        else:
            raise SeleniumError(
                "Can't find Selenium Driver Mode. %s" % cls.mode)

        cls.driver.implicitly_wait(DEFAULT_WAIT)
        cls.driver.set_window_size(WINDOW_SIZE_WIDTH, WINDOW_SIZE_HEIGHT)
        cls.driver.get(url)
        time.sleep(5)
开发者ID:TE-ToshiakiTanaka,项目名称:atve,代码行数:34,代码来源:module.py

示例3: _create_profile

 def _create_profile(self):
     """Create profile object.
     """
     profile = FirefoxProfile()
     for name, value in self.default_profile.items():
         profile.set_preference(name, value)
     return profile
开发者ID:TakesxiSximada,项目名称:pywad,代码行数:7,代码来源:firefox.py

示例4: test_pac_proxy_is_set_in_profile

def test_pac_proxy_is_set_in_profile():
    profile = FirefoxProfile()
    proxy = Proxy()
    proxy.proxy_autoconfig_url = 'http://some.url:12345/path'

    profile.set_proxy(proxy)
    assert profile.default_preferences["network.proxy.type"] == ProxyType.PAC['ff_value']
    assert profile.default_preferences["network.proxy.autoconfig_url"] == 'http://some.url:12345/path'
开发者ID:Allariya,项目名称:selenium,代码行数:8,代码来源:ff_profile_tests.py

示例5: SeleniumBaseTest

class SeleniumBaseTest(unittest.TestCase):

    def start_test_weblab_deployment(self):
        # Load the configuration of the weblab instance that we have set up for just this test.
        self.global_config = load_dir('test/deployments/webclient_dummy')

        # Start the weblab instance. Because we have activated the dont-start flag it won't actually
        # start listening on the port, but let us use the Flask test methods instead.
        self.handler = self.global_config.load_process('myhost', 'myprocess')

        self.core_server = GLOBAL_REGISTRY['mycore:[email protected]']

    @classmethod
    def setUpClass(self):

        # Starts a test deployment.
        self.start_test_weblab_deployment()

        if os.environ.get("SELENIUM_HEADLESS") and False:
            self.driver = webdriver.PhantomJS()
        else:
            self.profile = FirefoxProfile()
            self.profile.set_preference("intl.accept_languages", "en")
            self.driver = webdriver.Firefox(self.profile)

        self.driver.set_window_size(1400, 1000)

        # self.driver.implicitly_wait(30)

        self.base_url = "http://localhost:5000/"
        self.verificationErrors = []
        self.accept_next_alert = True

    def is_element_present(self, how, what):
        try: self.driver.find_element(by=how, value=what)
        except NoSuchElementException, e: return False
        return True

    def is_alert_present(self):
        try: self.driver.switch_to_alert()
        except NoAlertPresentException, e: return False
        return True

    def close_alert_and_get_its_text(self):
        try:
            alert = self.driver.switch_to_alert()
            alert_text = alert.text
            if self.accept_next_alert:
                alert.accept()
            else:
                alert.dismiss()
            return alert_text
        finally: self.accept_next_alert = True

    @classmethod
    def tearDownClass(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)
开发者ID:JamesHyunKim,项目名称:weblabdeusto,代码行数:58,代码来源:base.py

示例6: __init__

 def __init__(self, cer_data, key_data):
   
   self.temp_cer = self.temp_file(cer_data)
   self.temp_key = self.temp_file(key_data)
   profile = FirefoxProfile(settings.PROFILE_PATH)
   
   for preference in settings.PROFILE_PREFERENCES:
     profile.set_preference(*preference)
   
   self._driver = Firefox(firefox_profile = profile)
   self._driver.get(settings.GET_CFDI_URL)
开发者ID:Alkz6,项目名称:web_utilites,代码行数:11,代码来源:utils.py

示例7: __call__

 def __call__(self, config, args):
     profile = FirefoxProfile()
     if config.user_agent:
         profile.set_preference("general.useragent.override",
                                config.user_agent)
     if config.ignore_ssl:
         profile.accept_untrusted_certs = True
     args["firefox_profile"] = profile
     args["capabilities"] = args["desired_capabilities"]
     args.pop("desired_capabilities")
     return args
开发者ID:alisaifee,项目名称:holmium.core,代码行数:11,代码来源:config.py

示例8: test_add_extension_web_extension_without_id

def test_add_extension_web_extension_without_id(capabilities, webserver):
    current_directory = os.path.dirname(os.path.realpath(__file__))
    root_directory = os.path.join(current_directory, '..', '..', '..', '..', '..')
    extension_path = os.path.join(root_directory, 'third_party', 'firebug', 'mooltipass-1.1.87.xpi')

    profile = FirefoxProfile()
    profile.add_extension(extension_path)

    driver = Firefox(capabilities=capabilities, firefox_profile=profile)
    profile_path = driver.firefox_profile.path
    extension_path_in_profile = os.path.join(profile_path, 'extensions', '[email protected]')
    assert os.path.exists(extension_path_in_profile)
    driver.quit()
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:13,代码来源:ff_profile_tests.py

示例9: test_add_extension_legacy_extension

def test_add_extension_legacy_extension(capabilities, webserver):
    current_directory = os.path.dirname(os.path.realpath(__file__))
    root_directory = os.path.join(current_directory, '..', '..', '..', '..', '..')
    extension_path = os.path.join(root_directory, 'third_party', 'firebug', 'firebug-1.5.0-fx.xpi')

    profile = FirefoxProfile()
    profile.add_extension(extension_path)

    driver = Firefox(capabilities=capabilities, firefox_profile=profile)
    profile_path = driver.firefox_profile.path
    extension_path_in_profile = os.path.join(profile_path, 'extensions', '[email protected]')
    assert os.path.exists(extension_path_in_profile)
    driver.quit()
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:13,代码来源:ff_profile_tests.py

示例10: setUp

    def setUp(self):
        if _platform != "darwin":
            self.display = Display(visible=0, size=(1280, 800))
            self.display.start()

        p = FirefoxProfile()
        p.set_preference("webdriver.log.file", "/tmp/firefox_console")

        self.driver = webdriver.Firefox(p)
        self.base_url = os.getenv('SELENIUM_BASE_URL')
        self.verificationErrors = []
        self.accept_next_alert = True
        self.driver.set_window_size(1280, 800)
        self.project_name = "DBaaS"
开发者ID:globocom,项目名称:iaas-usage,代码行数:14,代码来源:base_functional_test.py

示例11: generate_profile

def generate_profile(useragent="(default)"):
    profile = FirefoxProfile()
    if useragent.strip().lower()=="(default)":
        status("Using the default useragent")
        return profile
    elif useragent.strip().lower()=="(random)":
        random_useragent = generate_user_agent(os=('mac', 'linux'))
        profile.set_preference("general.useragent.override", random_useragent) # To make our useragent random
        status("Using random useragent "+random_useragent)
        return profile
    else:
        profile.set_preference("general.useragent.override", useragent)
        status("Using useragent "+useragent)
        return profile
开发者ID:OWASP,项目名称:QRLJacking,代码行数:14,代码来源:browser.py

示例12: test_manual_proxy_is_set_in_profile

def test_manual_proxy_is_set_in_profile():
    profile = FirefoxProfile()
    proxy = Proxy()
    proxy.no_proxy = 'localhost, foo.localhost'
    proxy.http_proxy = 'some.url:1234'
    proxy.ftp_proxy = None
    proxy.sslProxy = 'some2.url'

    profile.set_proxy(proxy)
    assert profile.default_preferences["network.proxy.type"] == ProxyType.MANUAL['ff_value']
    assert profile.default_preferences["network.proxy.no_proxies_on"] == 'localhost, foo.localhost'
    assert profile.default_preferences["network.proxy.http"] == 'some.url'
    assert profile.default_preferences["network.proxy.http_port"] == 1234
    assert profile.default_preferences["network.proxy.ssl"] == 'some2.url'
    assert "network.proxy.ssl_port" not in profile.default_preferences
    assert "network.proxy.ftp" not in profile.default_preferences
开发者ID:Allariya,项目名称:selenium,代码行数:16,代码来源:ff_profile_tests.py

示例13: test_add_extension_web_extension_with_id

def test_add_extension_web_extension_with_id(capabilities, webserver):
    current_directory = os.path.dirname(os.path.realpath(__file__))
    root_directory = os.path.join(current_directory, '..', '..', '..', '..', '..')
    # TODO: This file should probably live in a common directory.
    extension_path = os.path.join(root_directory, 'javascript', 'node', 'selenium-webdriver',
                                  'lib', 'test', 'data', 'firefox', 'webextension.xpi')

    profile = FirefoxProfile()
    profile.add_extension(extension_path)

    driver = Firefox(capabilities=capabilities, firefox_profile=profile)
    profile_path = driver.firefox_profile.path
    extension_path_in_profile = os.path.join(profile_path, 'extensions', 'webextension[email protected]')
    assert os.path.exists(extension_path_in_profile)
    driver.get(webserver.where_is('simpleTest.html'))
    driver.find_element_by_id('webextensions-selenium-example')
    driver.quit()
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:17,代码来源:ff_profile_tests.py

示例14: setup_firefox_profile

    def setup_firefox_profile(self):
        """Return a custom firefox profile with given preferences
        and extensions.

        """
        fp = FirefoxProfile()

        if self.extensions:
            # Load extensions.
            for ext in self.extensions:
                fp.add_extension(ext)

        if self.preferences:
            # Load preferences
            for key, value in self.preferences:
                fp.set_preference(key, value)

        return fp
开发者ID:bluesurfer,项目名称:AuthTokens,代码行数:18,代码来源:crawler.py

示例15: test_that_unicode_prefs_are_written_in_the_correct_format

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,代码行数:19,代码来源:ff_profile_tests.py


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