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


Python firefox_profile.FirefoxProfile方法代码示例

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


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

示例1: _webdriver

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def _webdriver(self):
        className = self._driverClassName()
        self._remoteUsername = self._remoteUsername()
        remoteURL = self._remoteURL()
        capabilities = self._capabilities()
        if remoteURL:
            self.log("RemoteURL")
            # Remote driver requires a executor (typically a Remote URL)
            browserProfile = FirefoxProfile()
            return webdriver.Remote(command_executor = remoteURL, keep_alive = True, \
                browser_profile = browserProfile, desired_capabilities = capabilities)
        clazz = self._driverClass(className)
        try:
            self.log("" + className + "(capabilities)")
            return clazz(desired_capabilities = capabilities)
        except Exception:
            self.log("Setting up " + className)
            if className == 'PhantomJS':
                # PhantomJS cannot handle capabilities
                self.log("Creating " + className)
                return clazz()
            else:
                # Firefox and Ie drivers have different name for desired capabilities parameter
                #return clazz(capabilities = capabilities)
                return clazz() 
开发者ID:boozallen,项目名称:devsecops-example-helloworld,代码行数:27,代码来源:Container.py

示例2: profile

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def profile(self):
        """
            Returns a FirefoxProfile object if one has been set before else None

        """
        return self._profile 
开发者ID:boozallen,项目名称:devsecops-example-helloworld,代码行数:8,代码来源:options.py

示例3: __init__

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
                 capabilities=None, proxy=None):

        self.binary = firefox_binary
        self.profile = firefox_profile

        if self.profile is None:
            self.profile = FirefoxProfile()

        self.profile.native_events_enabled = (
            self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled)

        if self.binary is None:
            self.binary = FirefoxBinary()

        if capabilities is None:
            capabilities = DesiredCapabilities.FIREFOX

        if proxy is not None:
            proxy.add_to_capabilities(capabilities)

        RemoteWebDriver.__init__(self,
            command_executor=ExtensionConnection("127.0.0.1", self.profile,
            self.binary, timeout),
            desired_capabilities=capabilities,
            keep_alive=True)
        self._is_remote = False 
开发者ID:RoseOu,项目名称:flasky,代码行数:29,代码来源:webdriver.py

示例4: profile

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def profile(self, new_profile):
        """Sets location of the browser profile to use, either by string
        or ``FirefoxProfile``.

        """
        if not isinstance(new_profile, FirefoxProfile):
            new_profile = FirefoxProfile(new_profile)
        self._profile = new_profile 
开发者ID:thomasyimgit,项目名称:leetcode,代码行数:10,代码来源:options.py

示例5: fetch

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def fetch(config, fileobj):
    user, password = config

    # use the user's regular firefox profile instead of a fresh temporary one.
    # this is to avoid getting fingerprinted as a new device which generates
    # annoying emails and asks for additional info. luckily this profile is
    # cloned into a temporary directory, so we can change preferences without
    # affecting the original copy.
    profile = FirefoxProfile(_firefox_default_profile())
    # disable a json viewer that's enabled by default in firefox 53+.
    profile.set_preference('devtools.jsonview.enabled', False)
    driver = Firefox(profile)
    
    driver.get('https://venmo.com/account/sign-in/')
    user_elem = driver.find_element_by_name('phoneEmailUsername')
    user_elem.clear()
    user_elem.send_keys(user.value)
    password_elem = driver.find_element_by_name('password')
    password_elem.clear()
    password_elem.send_keys(password.value)
    password_elem.send_keys(Keys.RETURN)

    WebDriverWait(driver, 15).until(title_contains('Welcome'))

    params = '?start_date=2009-01-01&end_date={}-01-01'.format(datetime.now().year + 1)
    url = 'https://api.venmo.com/v1/transaction-history' + params
    driver.get(url)

    # validate json and raise ValueError on failure.
    pre = driver.find_element_by_tag_name('pre').text
    json.loads(pre)

    driver.quit()
    fileobj.write('{}\n'.format(user.value))
    fileobj.write(pre) 
开发者ID:tmerr,项目名称:bank_wrangler,代码行数:37,代码来源:venmo.py

示例6: test_accepts_firefox_profile

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def test_accepts_firefox_profile(self, browser_manager, webserver):
        from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
        home_page = webserver.path_for('special_chars.html')

        profile = FirefoxProfile()
        profile.set_preference('browser.startup.homepage', home_page)
        profile.set_preference('browser.startup.page', 1)
        kwargs = browser_manager.kwargs.copy()
        kwargs['options'] = {'profile': profile}

        new_browser = Browser(**kwargs)
        try:
            assert new_browser.url == home_page
        finally:
            new_browser.quit() 
开发者ID:watir,项目名称:nerodia,代码行数:17,代码来源:browser_tests.py

示例7: __init__

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
                 capabilities=None, proxy=None, executable_path="wires", firefox_options=None):
        capabilities = capabilities or DesiredCapabilities.FIREFOX.copy()

        self.profile = firefox_profile or FirefoxProfile()
        self.profile.native_events_enabled = (
            self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled)

        self.binary = firefox_binary or capabilities.get("binary", FirefoxBinary())

        self.options = firefox_options or Options()
        self.options.binary_location = self.binary if isinstance(self.binary, basestring) else self.binary._start_cmd
        self.options.profile = self.profile
        capabilities.update(self.options.to_capabilities())

        # marionette
        if capabilities.get("marionette"):
            self.service = Service(executable_path, firefox_binary=self.options.binary_location)
            self.service.start()

            executor = FirefoxRemoteConnection(
                remote_server_addr=self.service.service_url)
            RemoteWebDriver.__init__(
                self,
                command_executor=executor,
                desired_capabilities=capabilities,
                keep_alive=True)
        else:
            # Oh well... sometimes the old way is the best way.
            if proxy is not None:
                proxy.add_to_capabilities(capabilities)

            executor = ExtensionConnection("127.0.0.1", self.profile,
                                           self.binary, timeout)
            RemoteWebDriver.__init__(
                self,
                command_executor=executor,
                desired_capabilities=capabilities,
                keep_alive=True)

        self._is_remote = False 
开发者ID:drewctate,项目名称:amazon_order_history_scraper,代码行数:43,代码来源:webdriver.py

示例8: setUpClass

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def setUpClass(cls):
        super(SeleniumTests, cls).setUpClass()
        cls.firefox_profile = FirefoxProfile()
        server_url = config('TEST_PUSH_SERVER_URL', default=False)
        if server_url:
            cls.firefox_profile.set_preference('dom.push.serverURL',
                                               server_url)
        cls.selenium = WebDriver(firefox_profile=cls.firefox_profile) 
开发者ID:mozilla-services,项目名称:push-dev-dashboard,代码行数:10,代码来源:test_e2e.py

示例9: StartBrowser

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [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:HoussemCharf,项目名称:FunUtils,代码行数:60,代码来源:linkedinViewerBot.py

示例10: __init__

# 需要导入模块: from selenium.webdriver.firefox import firefox_profile [as 别名]
# 或者: from selenium.webdriver.firefox.firefox_profile import FirefoxProfile [as 别名]
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
                 capabilities=None, proxy=None, executable_path="wires"):
        self.binary = firefox_binary
        self.profile = firefox_profile

        if self.profile is None:
            self.profile = FirefoxProfile()

        self.profile.native_events_enabled = (
            self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled)

        if capabilities is None:
            capabilities = DesiredCapabilities.FIREFOX

        # marionette
        if capabilities.get("marionette"):
            self.binary = capabilities.get("binary")
            self.service = Service(executable_path, firefox_binary=self.binary)
            self.service.start()

            executor = FirefoxRemoteConnection(
                remote_server_addr=self.service.service_url)
            RemoteWebDriver.__init__(
                self,
                command_executor=executor,
                desired_capabilities=capabilities,
                keep_alive=True)
        else:
            # Oh well... sometimes the old way is the best way.
            if self.binary is None:
                self.binary = FirefoxBinary()

            if proxy is not None:
                proxy.add_to_capabilities(capabilities)

            executor = ExtensionConnection("127.0.0.1", self.profile,
                                           self.binary, timeout)
            RemoteWebDriver.__init__(self,
                command_executor=executor,
            desired_capabilities=capabilities,
            keep_alive=True)


        self._is_remote = False 
开发者ID:aploium,项目名称:ShuoshuoMonitor,代码行数:46,代码来源:webdriver.py

示例11: launch_browser

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

    if env.RUNNING_BROWSER.upper() == "FIREFOX":
        # the end of the browser process , the end of the browser driven process
        os.popen("TASKKILL /F /IM firefoxdriver.exe")

        fp = FirefoxProfile()
        fp.native_events_enabled = False

        binary_path = PublicImp.common.get_value_from_conf("FIREFOX_BINARY_PATH")

        if binary_path == "":
            env.driver = selenium.webdriver.Firefox(firefox_profile=fp)
        else:
            fb = FirefoxBinary(firefox_path=binary_path)
            env.driver = selenium.webdriver.Firefox(firefox_profile=fp, firefox_binary=fb)

    elif env.RUNNING_BROWSER.upper() == "CHROME":
        os.popen("TASKKILL /F /IM chromedriver.exe")

        binary_path = PublicImp.common.get_value_from_conf("CHROME_BINARY_PATH")
        chromedriver = PublicImp.common.get_value_from_conf("DRIVER_CHROME")

        if binary_path == "":
            os.environ["webdriver.chrome.driver"] = chromedriver
            env.driver = selenium.webdriver.Chrome(executable_path=chromedriver)
        else:
            opts = Options()
            opts.binary_location = binary_path
            os.environ["webdriver.chrome.driver"] = chromedriver
            env.driver = selenium.webdriver.Chrome(executable_path=chromedriver, chrome_options=opts)

    elif env.RUNNING_BROWSER.upper() == "IE":
        os.popen("TASKKILL /F /IM IEDriverServer.exe")

        dc = DesiredCapabilities.INTERNETEXPLORER.copy()

        dc['acceptSslCerts'] = True
        dc['nativeEvents'] = True

        iedriver = PublicImp.common.get_value_from_conf("DRIVER_IE")
        os.environ["webdriver.ie.driver"] = iedriver
        env.driver = selenium.webdriver.Ie(executable_path=iedriver, capabilities=dc)

    else:
        return False

    env.platformName = env.RUNNING_BROWSER

    env.TEST_URL = PublicImp.common.get_value_from_conf("TESTING_URL")
    env.driver.get(env.TEST_URL)
    env.driver.maximize_window()

    time.sleep(3)
    env.driver.refresh()
    # env.driver.set_window_size(480, 800)
    time.sleep(3)

    return True 
开发者ID:yzwy1988,项目名称:YOHO_Automated_Test,代码行数:61,代码来源:executer.py


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