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


Python browser.browser函数代码示例

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


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

示例1: check_logged_out

def check_logged_out():
    if browser.browser() is not None:
        browser.quit()
        browser.ensure_browser_open()
        login.logout()
    yield
    if browser.browser() is not None:
        browser.quit()
        browser.ensure_browser_open()
        login.logout()
开发者ID:FilipB,项目名称:cfme_tests,代码行数:10,代码来源:test_login.py

示例2: generated_request

def generated_request(provider, provider_data, provisioning, template_name, vm_name):
    """Creates a provision request, that is not automatically approved, and returns the search data.

    After finishing the test, request should be automatically deleted.

    Slightly modified code from :py:module:`cfme.tests.infrastructure.test_provisioning`
    """
    first_name = fauxfactory.gen_alphanumeric()
    last_name = fauxfactory.gen_alphanumeric()
    notes = fauxfactory.gen_alphanumeric()
    e_mail = "{}@{}.test".format(first_name, last_name)
    host, datastore = map(provisioning.get, ('host', 'datastore'))
    pytest.sel.force_navigate('infrastructure_provision_vms', context={
        'provider': provider,
        'template_name': template_name,
    })

    provisioning_data = {
        'email': e_mail,
        'first_name': first_name,
        'last_name': last_name,
        'notes': notes,
        'vm_name': vm_name,
        'host_name': {'name': [host]},
        'datastore_name': {'name': [datastore]},
        'num_vms': "10",    # so it won't get auto-approved
    }

    # Same thing, different names. :\
    if provider_data["type"] == 'rhevm':
        provisioning_data['provision_type'] = 'Native Clone'
    elif provider_data["type"] == 'virtualcenter':
        provisioning_data['provision_type'] = 'VMware'

    try:
        provisioning_data['vlan'] = provisioning['vlan']
    except KeyError:
        # provisioning['vlan'] is required for rhevm provisioning
        if provider_data["type"] == 'rhevm':
            raise pytest.fail('rhevm requires a vlan value in provisioning info')

    provisioning_form.fill(provisioning_data)
    pytest.sel.click(provisioning_form.submit_button)
    flash.assert_no_errors()
    request_cells = {
        "Description": "Provision from [{}] to [{}###]".format(template_name, vm_name),
    }
    yield request_cells

    browser().get(store.base_url)
    login_admin()

    requests.delete_request(request_cells)
    flash.assert_no_errors()
开发者ID:FilipB,项目名称:cfme_tests,代码行数:54,代码来源:test_operations.py

示例3: really_logout

def really_logout():
    """A convenience function logging out

    This function simply ensures that we are logged out and that a new browser is loaded
    ready for use.
    """
    try:
        current_appliance.server.logout()
    except AttributeError:
        try:
            browser().quit()
        except AttributeError:
            ensure_browser_open()
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:13,代码来源:rbac.py

示例4: generated_request

def generated_request(provider, provider_data, provisioning, template_name, vm_name):
    """Creates a provision request, that is not automatically approved, and returns the search data.

    After finishing the test, request should be automatically deleted.

    Slightly modified code from :py:module:`cfme.tests.infrastructure.test_provisioning`
    """
    first_name = fauxfactory.gen_alphanumeric()
    last_name = fauxfactory.gen_alphanumeric()
    notes = fauxfactory.gen_alphanumeric()
    e_mail = "{}@{}.test".format(first_name, last_name)
    host, datastore = map(provisioning.get, ("host", "datastore"))
    vm = Vm(name=vm_name, provider=provider, template_name=template_name)
    navigate_to(vm, "ProvisionVM")

    provisioning_data = {
        "email": e_mail,
        "first_name": first_name,
        "last_name": last_name,
        "notes": notes,
        "vm_name": vm_name,
        "host_name": {"name": [host]},
        "datastore_name": {"name": [datastore]},
        "num_vms": "10",  # so it won't get auto-approved
    }

    # Same thing, different names. :\
    if provider_data["type"] == "rhevm":
        provisioning_data["provision_type"] = "Native Clone"
    elif provider_data["type"] == "virtualcenter":
        provisioning_data["provision_type"] = "VMware"

    try:
        provisioning_data["vlan"] = provisioning["vlan"]
    except KeyError:
        # provisioning['vlan'] is required for rhevm provisioning
        if provider_data["type"] == "rhevm":
            raise pytest.fail("rhevm requires a vlan value in provisioning info")

    fill(provisioning_form, provisioning_data, action=provisioning_form.submit_button)
    flash.assert_no_errors()
    request_cells = {"Description": "Provision from [{}] to [{}###]".format(template_name, vm_name)}
    yield request_cells

    browser().get(store.base_url)
    login_admin()

    requests.delete_request(request_cells)
    flash.assert_no_errors()
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:49,代码来源:test_operations.py

示例5: move_to_element

def move_to_element(loc, **kwargs):
    """
    Moves to an element.

    Args:
        loc: A locator, expects either a string, WebElement, tuple.
    Returns: Returns the element it was moved to to enable chaining.
    """
    brand = "//div[@id='page_header_div']//div[contains(@class, 'brand')]"
    wait_for_ajax()
    el = element(loc, **kwargs)
    move_to = ActionChains(browser()).move_to_element(el)
    try:
        move_to.perform()
    except MoveTargetOutOfBoundsException:
        # ff workaround
        execute_script("arguments[0].scrollIntoView();", el)
        if elements(brand) and not is_displayed(brand):
            # If it does it badly that it moves whole page, this moves it back
            try:
                execute_script("arguments[0].scrollIntoView();", element(brand))
            except MoveTargetOutOfBoundsException:
                pass
        try:
            move_to.perform()
        except MoveTargetOutOfBoundsException:  # This has become desperate now.
            raise exceptions.CannotScrollException(
                "Despite all the workarounds, scrolling to `{}` was unsuccessful.".format(loc))
    return el
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:29,代码来源:pytest_selenium.py

示例6: needs_firefox

def needs_firefox():
    """ Fixture which skips the test if not run under firefox.

    I recommend putting it in the first place.
    """
    if browser.browser().name != "firefox":
        pytest.skip(msg="This test needs firefox to run")
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:7,代码来源:test_download_report.py

示例7: click

def click(loc, wait_ajax=True, no_custom_handler=False):
    """
    Clicks on an element.

    If the element implements `_custom_click_handler` the control will be given to it. Then the
    handler decides what to do (eg. do not click under some circumstances).

    Args:
        loc: A locator, expects either a string, WebElement, tuple or an object implementing
            `_custom_click_handler` method.
        wait_ajax: Whether to wait for ajax call to finish. Default True but sometimes it's
            handy to not do that. (some toolbar clicks)
        no_custom_handler: To prevent recursion, the custom handler sets this to True.
    """
    if hasattr(loc, "_custom_click_handler") and not no_custom_handler:
        # Object can implement own modification of click behaviour
        return loc._custom_click_handler()

    # Move mouse cursor to element
    move_to_element(loc)
    # and then click on current mouse position
    ActionChains(browser()).click().perform()
    # -> using this approach, we don't check if we clicked a specific element
    if wait_ajax:
        wait_for_ajax()
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:25,代码来源:pytest_selenium.py

示例8: move_to_element

def move_to_element(loc, **kwargs):
    """
    Moves to an element.

    Args:
        loc: A locator, expects either a string, WebElement, tuple.
    Returns: It passes `loc` through to make it possible to use in case we want to immediately use
        the element that it is being moved to.
    """
    brand = "//div[@id='page_header_div']//div[contains(@class, 'brand')]"
    wait_for_ajax()
    el = element(loc, **kwargs)
    move_to = ActionChains(browser()).move_to_element(el)
    try:
        move_to.perform()
    except MoveTargetOutOfBoundsException:
        # ff workaround
        execute_script("arguments[0].scrollIntoView();", el)
        if elements(brand) and not is_displayed(brand):
            # If it does it badly that it moves whole page, this moves it back
            try:
                execute_script("arguments[0].scrollIntoView();", element(brand))
            except MoveTargetOutOfBoundsException:
                pass
        move_to.perform()
    return el
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:26,代码来源:pytest_selenium.py

示例9: current_url

def current_url():
    """
    Returns the current_url of the page

    Returns: A url.
    """
    return browser().current_url
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:7,代码来源:pytest_selenium.py

示例10: get_logging_url

    def get_logging_url(self):

        def report_kibana_failure():
            raise RuntimeError("Kibana not found in the window title or content")

        browser_instance = browser()

        all_windows_before = browser_instance.window_handles
        appliance_window = browser_instance.current_window_handle

        self.monitor.item_select('External Logging')

        all_windows_after = browser_instance.window_handles

        new_windows = set(all_windows_after) - set(all_windows_before)

        if not new_windows:
            raise RuntimeError("No logging window was open!")

        logging_window = new_windows.pop()
        browser_instance.switch_to_window(logging_window)

        logging_url = browser_instance.current_url

        wait_for(lambda: "kibana" in
                         browser_instance.title.lower() + " " +
                         browser_instance.page_source.lower(),
                 fail_func=report_kibana_failure, num_sec=60, delay=5)

        browser_instance.close()
        browser_instance.switch_to_window(appliance_window)

        return logging_url
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:33,代码来源:__init__.py

示例11: move_to_element

def move_to_element(loc):
    """
    Moves to an element.

    Args:
        loc: A locator, expects either a string, WebElement, tuple.
    """
    ActionChains(browser()).move_to_element(element(loc)).perform()
开发者ID:kbrock,项目名称:cfme_tests,代码行数:8,代码来源:pytest_selenium.py

示例12: get

def get(url):
    """
    Changes page to the spceified URL

    Args:
        url: URL to navigate to.
    """
    return browser().get(url)
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:8,代码来源:pytest_selenium.py

示例13: _t

def _t(t, root=None):
    """Assume tuple is a 2-item tuple like (By.ID, 'myid').

    Handles the case when root= locator resolves to multiple elements. In that case all of them
    are processed and all results are put in the same list."""
    result = []
    for root_element in (elements(root) if root is not None else [browser()]):
        result += root_element.find_elements(*t)
    return result
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:9,代码来源:pytest_selenium.py

示例14: drag_and_drop

def drag_and_drop(source_element, dest_element):
    """Drag and Drop element.

    Args:
        loc: A locator, expects either a string, WebElement, tuple.
        wait_ajax: Whether to wait for ajax call to finish. Default True but sometimes it's
            handy to not do that. (some toolbar clicks)
    """
    ActionChains(browser()).drag_and_drop(dest_element, source_element).perform()
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:9,代码来源:pytest_selenium.py

示例15: navigate_accordions

def navigate_accordions(accordions, page_name, ui_bench_pg_limit, ui_worker_pid, prod_tail,
        soft_assert):
    pages = []
    for acc_tree in accordions:
        pages.extend(analyze_page_stat(perf_click(ui_worker_pid, prod_tail, True, accordion.click,
            acc_tree), soft_assert))

        logger.info('Starting to read tree: {}'.format(acc_tree))
        tree_contents, sel_time = perf_bench_read_tree(accordion.tree(acc_tree))
        logger.info('{} tree read in {}ms'.format(acc_tree, sel_time))

        pages.extend(analyze_page_stat(perf_click(ui_worker_pid, prod_tail, False, None),
            soft_assert))

        nav_limit = 0
        count = -1
        if accordions[acc_tree] in ui_bench_pg_limit:
            nav_limit = ui_bench_pg_limit[accordions[acc_tree]]
            count = 0

        paths = []
        generate_tree_paths(tree_contents, [], paths)
        logger.info('Found {} tree paths'.format(len(paths)))
        for path in paths:
            logger.info('Navigating to: {}, {}'.format(acc_tree, path[-1]))
            try:
                pages.extend(analyze_page_stat(perf_click(ui_worker_pid, prod_tail, True,
                    accordion.tree(acc_tree).click_path, *path), soft_assert))
                count += 1
                # Navigate out of the page every 4th click
                if (count % 4) == 0:
                    pages.extend(analyze_page_stat(perf_click(ui_worker_pid, prod_tail, False,
                        sel.force_navigate, 'dashboard'), soft_assert))
                    pages.extend(analyze_page_stat(perf_click(ui_worker_pid, prod_tail, False,
                        sel.force_navigate, page_name), soft_assert))
            except CandidateNotFound:
                logger.info('Could not navigate to: '.format(path[-1]))
            except UnexpectedAlertPresentException:
                logger.warning('UnexpectedAlertPresentException - page_name: {}, accordion: {},'
                    ' path: {}'.format(page_name, acc_tree, path[-1]))
                browser().switch_to_alert().dismiss()
            if not nav_limit == 0 and count >= nav_limit:
                break
    return pages
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:44,代码来源:pagestats.py


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