• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python browser.ensure_browser_open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setup_external_auth_openldap

def setup_external_auth_openldap(**data):
    """Sets up the appliance for an external authentication with OpenLdap.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaddress'],
    }
    appliance_obj = appliance.IPAppliance()
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = appliance_obj.address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['domain_name'])
    ldapserver_ssh = SSHClient(**connect_kwargs)
    # updating the /etc/hosts is a workaround due to the
    # https://bugzilla.redhat.com/show_bug.cgi?id=1360928
    command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
    ldapserver_ssh.run_command(command)
    ldapserver_ssh.get_file(remote_file=data['cert_filepath'],
                            local_path=conf_path.strpath)
    ldapserver_ssh.close()
    ensure_browser_open()
    login_admin()
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", True))
    auth.setup()
    appliance_obj.configure_appliance_for_openldap_ext_auth(appliance_fqdn)
    logout()
开发者ID:rananda,项目名称:cfme_tests,代码行数:32,代码来源:ext_auth.py


示例2: setup_external_auth_ipa

def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    ssh = SSHClient()
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    logout()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    rc, out = ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data)
    )
    assert rc == 0, out
    assert "failed" not in out.lower(), "External auth setup failed:\n{}".format(out)
    login_admin()
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:27,代码来源:ext_auth.py


示例3: step

 def step(self):
     # Can be either blank or logged in
     del self.view  # In order to unbind the browser
     quit()
     ensure_browser_open(self.obj.appliance.server.address())
     if not self.view.is_displayed:
         raise Exception('Could not open the login screen')
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:7,代码来源:ssui.py


示例4: needs_firefox

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

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


示例5: force_navigate

def force_navigate(page_name, _tries=0, *args, **kwargs):
    """force_navigate(page_name)

    Given a page name, attempt to navigate to that page no matter what breaks.

    Args:
        page_name: Name a page from the current :py:data:`ui_navigate.nav_tree` tree to navigate to.

    """
    if _tries >= 3:
        # Need at least three tries:
        # 1: login_admin handles an alert or closes the browser due any error
        # 2: If login_admin handles an alert, go_to can still encounter an unexpected error
        # 3: Everything should work. If not, NavigationError.
        raise exceptions.NavigationError(page_name)

    _tries += 1

    logger.debug('force_navigate to %s, try %d' % (page_name, _tries))
    # circular import prevention: cfme.login uses functions in this module
    from cfme import login
    # Import the top-level nav menus for convenience
    from cfme.web_ui import menu  # NOQA

    # browser fixture should do this, but it's needed for subsequent calls
    ensure_browser_open()

    # Clear any running "spinnies"
    try:
        browser().execute_script('miqSparkleOff();')
    except:
        # miqSparkleOff undefined, so it's definitely off.
        pass

    try:
        # What we'd like to happen...
        login.login_admin()
        logger.info('Navigating to %s' % page_name)
        ui_navigate.go_to(page_name, *args, **kwargs)
    except (KeyboardInterrupt, ValueError):
        # KeyboardInterrupt: Don't block this while navigating
        # ValueError: ui_navigate.go_to can't handle this page, give up
        raise
    except UnexpectedAlertPresentException:
        if _tries == 1:
            # There was an alert, accept it and try again
            handle_alert(wait=0)
        else:
            # There was still an alert when we tried again, shoot the browser in the head
            logger.debug("Unxpected alert on try %d, recycling browser" % _tries)
            browser().quit()
        force_navigate(page_name, _tries, *args, **kwargs)
    except Exception as ex:
        # Anything else happened, nuke the browser and try again.
        logger.info('Caught %s during navigation, trying again.' % type(ex).__name__)
        logger.debug(format_exc())
        browser().quit()
        force_navigate(page_name, _tries, *args, **kwargs)
开发者ID:kbrock,项目名称:cfme_tests,代码行数:58,代码来源:pytest_selenium.py


示例6: disable_external_auth_ipa

def disable_external_auth_ipa():
    """Unconfigure external auth."""
    ssh = SSHClient()
    ensure_browser_open()
    login_admin()
    auth = DatabaseAuthSetting()
    auth.update()
    rc, out = ssh.run_command("appliance_console_cli --uninstall-ipa")
    assert rc == 0, out
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:9,代码来源:ext_auth.py


示例7: standup_perf_ui

def standup_perf_ui(ui_worker_pid, soft_assert):
    logger.info('Opening /var/www/miq/vmdb/log/production.log for tail')
    prod_tail = SSHTail('/var/www/miq/vmdb/log/production.log')
    prod_tail.set_initial_file_end()

    ensure_browser_open()
    pages = analyze_page_stat(perf_click(ui_worker_pid, prod_tail, False, login_admin), soft_assert)

    return pages, prod_tail
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:9,代码来源:pagestats.py


示例8: disable_external_auth_ipa

def disable_external_auth_ipa():
    """Unconfigure external auth."""
    ssh = SSHClient()
    ensure_browser_open()
    login_admin()
    auth = DatabaseAuthSetting()
    auth.update()
    assert ssh.run_command("appliance_console_cli --uninstall-ipa")
    appliance.IPAppliance().wait_for_web_ui()
    logout()
开发者ID:rananda,项目名称:cfme_tests,代码行数:10,代码来源:ext_auth.py


示例9: 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


示例10: test_basic_metrics

def test_basic_metrics(provider):
    """ Basic Metrics availability test
        This test checks that the Metrics service is up
        Opens the hawkular status page and checks if it's up
        """
    hostname = 'https://' + conf.cfme_data.get('management_systems', {})[provider.key]\
        .get('hostname', []) + '/hawkular/metrics'
    ensure_browser_open()
    sel.get(hostname)
    element = sel.ByText('STARTED')
    assert element
开发者ID:FilipB,项目名称:cfme_tests,代码行数:11,代码来源:test_basic_metrics.py


示例11: disable_external_auth_ipa

def disable_external_auth_ipa():
    """Unconfigure external auth."""
    current_appliance = get_or_create_current_appliance()
    with current_appliance.ssh_client as ssh:
        ensure_browser_open()
        appliance.current_appliance.server.login_admin()
        auth = DatabaseAuthSetting()
        auth.update()
        assert ssh.run_command("appliance_console_cli --uninstall-ipa")
        current_appliance.wait_for_web_ui()
    appliance.current_appliance.server.logout()
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:11,代码来源:ext_auth.py


示例12: login

def login(user, submit_method=_js_auth_fn):
    """
    Login to CFME with the given username and password.
    Optionally, submit_method can be press_enter_after_password
    to use the enter key to login, rather than clicking the button.

    Args:
        user: The username to fill in the username field.
        password: The password to fill in the password field.
        submit_method: A function to call after the username and password have been input.

    Raises:
        RuntimeError: If the login fails, ie. if a flash message appears
    """

    if not user:
        username = conf.credentials['default']['username']
        password = conf.credentials['default']['password']
        cred = Credential(principal=username, secret=password)
        user = User(credential=cred)

    if not logged_in() or user.credential.principal is not current_username():
        if logged_in():
            logout()
        # workaround for strange bug where we are logged out
        # as soon as we click something on the dashboard
        sel.sleep(1.0)

        logger.debug('Logging in as user %s', user.credential.principal)
        try:
            fill(form, {'username': user.credential.principal, 'password': user.credential.secret})
        except sel.InvalidElementStateException as e:
            logger.warning("Got an error. Details follow.")
            msg = str(e).lower()
            if "element is read-only" in msg:
                logger.warning("Got a read-only login form, will reload the browser.")
                # Reload browser
                quit()
                ensure_browser_open()
                sel.sleep(1.0)
                sel.wait_for_ajax()
                # And try filling the form again
                fill(form, {'username': user.credential.principal,
                    'password': user.credential.secret})
            else:
                logger.warning("Unknown error, reraising.")
                logger.exception(e)
                raise
        with sel.ajax_timeout(90):
            submit_method()
        flash.assert_no_errors()
        user.full_name = _full_name()
        store.user = user
开发者ID:FilipB,项目名称:cfme_tests,代码行数:53,代码来源:login.py


示例13: logged_in

def logged_in(browser):
    """
    Logs into the system as admin and then returns the browser object.

    Args:
        browser: Current browser object.

    Yields: Browser object
    """
    ensure_browser_open()
    login_admin()
    yield browser()
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:12,代码来源:login.py


示例14: 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


示例15: _on_detail_page

 def _on_detail_page(self):
     """ Returns ``True`` if on the providers detail page, ``False`` if not."""
     if not self.string_name:
         # No point in doing that since it is probably being called from badly configured class
         # And since it is badly configured, let's notify the user.
         logger.warning(
             'Hey, _on_details_page called from {} class which does not have string_name set'
             .format(type(self).__name__))
         return False
     ensure_browser_open()
     collection = '{} Providers'.format(self.string_name)
     title = '{} (Summary)'.format(self.name)
     return breadcrumbs_names() == [collection, title] and summary_title() == title
开发者ID:rananda,项目名称:cfme_tests,代码行数:13,代码来源:provider.py


示例16: step

 def step(self):
     # Can be either blank or logged in
     from utils import browser
     logged_in_view = self.create_view(BaseLoggedInPage)
     if logged_in_view.logged_in:
         logged_in_view.logout()
     if not self.view.is_displayed:
         # Something is wrong
         del self.view  # In order to unbind the browser
         browser.quit()
         browser.ensure_browser_open(self.obj.appliance.server.address())
         if not self.view.is_displayed:
             raise Exception('Could not open the login screen')
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:13,代码来源:ui.py


示例17: setup_external_auth_ipa

def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    current_appliance = get_or_create_current_appliance()
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = current_appliance.address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    with SSHClient(**connect_kwargs) as ipaserver_ssh:
        ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
        ipaserver_ssh.run_command("sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
        command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
        ipaserver_ssh.run_command(command)
    with current_appliance.ssh_client as ssh:
        result = ssh.run_command('appliance_console_cli --host {}'.format(appliance_fqdn)).success
        if not current_appliance.is_pod:
            assert result
        else:
            # appliance_console_cli fails when calls hostnamectl --host. it seems docker issue
            # raise BZ ?
            assert str(ssh.run_command('hostname')).rstrip() == appliance_fqdn

        ensure_browser_open()
        appliance.current_appliance.server.login_admin()
        if data["ipaserver"] not in get_ntp_servers():
            set_ntp_servers(data["ipaserver"])
            sleep(120)
        auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
        auth.setup()
        creds = credentials.get(data.pop("credentials"), {})
        data.update(**creds)
        assert ssh.run_command(
            "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
            "--ipaprincipal {principal} --ipapassword {password}".format(**data)
        )
    appliance.current_appliance.server.login_admin()
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:46,代码来源:ext_auth.py


示例18: setup_external_auth_ipa

def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    import fauxfactory
    appliance_name = 'cfmeappliance'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = appliance.IPAppliance().address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    ipaserver_ssh = SSHClient(**connect_kwargs)
    # updating the /etc/hosts is a workaround due to the
    # https://bugzilla.redhat.com/show_bug.cgi?id=1360928
    command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
    ipaserver_ssh.run_command(command)
    ipaserver_ssh.close()
    ssh = SSHClient()
    rc, out = ssh.run_command('appliance_console_cli --host {}'.format(appliance_fqdn))
    assert rc == 0, out
    ssh.run_command('echo "127.0.0.1\t{}" > /etc/hosts'.format(appliance_fqdn))
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    logout()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    rc, out = ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data)
    )
    assert rc == 0, out
    assert "failed" not in out.lower(), "External auth setup failed:\n{}".format(out)
    login_admin()
开发者ID:FilipB,项目名称:cfme_tests,代码行数:45,代码来源:ext_auth.py


示例19: local_setup_provider

def local_setup_provider(request, setup_provider_modscope, provider, vm_analysis_data):
    if provider.type == 'rhevm' and version.current_version() < "5.5":
        # See https://bugzilla.redhat.com/show_bug.cgi?id=1300030
        pytest.skip("SSA is not supported on RHEVM for appliances earlier than 5.5 and upstream")
    if GH("ManageIQ/manageiq:6506").blocks:
        pytest.skip("Upstream provisioning is blocked by" +
                    "https://github.com/ManageIQ/manageiq/issues/6506")
    if provider.type == 'virtualcenter':
        store.current_appliance.install_vddk(reboot=True, wait_for_web_ui_after_reboot=True)
        ensure_browser_open()
        set_host_credentials(request, provider, vm_analysis_data)

    # Make sure all roles are set
    roles = configuration.get_server_roles(db=False)
    roles["automate"] = True
    roles["smartproxy"] = True
    roles["smartstate"] = True
    configuration.set_server_roles(**roles)
开发者ID:anewmanRH,项目名称:cfme_tests,代码行数:18,代码来源:test_instance_analysis.py


示例20: setup_external_auth_ipa

def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = appliance.IPAppliance().address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    ipaserver_ssh = SSHClient(**connect_kwargs)
    ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
    ipaserver_ssh.run_command("sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
    command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
    ipaserver_ssh.run_command(command)
    ipaserver_ssh.close()
    ssh = SSHClient()
    assert ssh.run_command('appliance_console_cli --host {}'.format(appliance_fqdn))
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    assert ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data)
    )
    login_admin()
开发者ID:rananda,项目名称:cfme_tests,代码行数:39,代码来源:ext_auth.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python captcha.Captcha类代码示例发布时间:2022-05-26
下一篇:
Python browser.browser函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap