def test_summary_pages_links(provider, cls):

    navigate_to(cls.object, "All")
    all_url = sel.current_url()
    tb.select("List View")
    name = choice([r[2].text for r in list_tbl.rows()])
    obj = cls.object(name, provider)
    obj.summary  # <- reload summary

    breads = breadcrumbs()
    bread_names = map(sel.text_sane, breads)

    if cls.breadcrumb_member.startswith("Container") and cls.breadcrumb_member not in bread_names:
        breadcrumb_member = cls.breadcrumb_member.split(" ")[-1]
    else:
        breadcrumb_member = cls.breadcrumb_member

    assert breadcrumb_member in bread_names

    chosen_link = next(b for b in breads if sel.text_sane(b) == breadcrumb_member)

    sel.click(chosen_link)

    # TODO: replace with widgetastic view.is_displayed function when available
    assert sel.current_url().split("?")[0] == all_url.split("?")[0]
Пример #2
0
    def update(self, updates, cancel=False, validate_credentials=False):
        """
        Updates a host in the UI.  Better to use utils.update.update context
        manager than call this directly.

        Args:
           updates (dict): fields that are changing.
           cancel (boolean): whether to cancel out of the update.
        """

        sel.force_navigate('infrastructure_host_edit', context={'host': self})
        change_stored_password()
        fill(credential_form, updates.get('credentials', None), validate=validate_credentials)

        # Workaround for issue with form_button staying dimmed.
        try:
            logger.debug("Trying to save update for host with id: " + str(self.get_db_id))
            self._submit(cancel, self.forced_saved)
            logger.debug("save worked, no exception")
        except Exception as e:
            logger.debug("exception detected: " + str(e))
            sel.browser().execute_script(
                "$j.ajax({type: 'POST', url: '/host/form_field_changed/%s',"
                " data: {'default_userid':'%s'}})" %
                (str(sel.current_url().split('/')[5]), updates.get('credentials', None).principal))
            sel.browser().execute_script(
                "$j.ajax({type: 'POST', url: '/host/form_field_changed/%s',"
                " data: {'default_password':'******'}})" %
                (str(sel.current_url().split('/')[5]), updates.get('credentials', None).secret))
            sel.browser().execute_script(
                "$j.ajax({type: 'POST', url: '/host/form_field_changed/%s',"
                " data: {'default_verify':'%s'}})" %
                (str(sel.current_url().split('/')[5]),
                    updates.get('credentials', None).verify_secret))
            self._submit(cancel, self.forced_saved)
Пример #3
0
def test_services_request_direct_url(generated_request):
    """Go to the request page, save the url and try to access it directly."""
    assert requests.go_to_request(generated_request), "could not find the request!"
    request_url = sel.current_url()
    sel.get(sel.base_url())    # I need to flip it with something different here
    sel.get(request_url)        # Ok, direct access now.
    wait_for(
        lambda: sel.is_displayed("//body[contains(@onload, 'miqOnLoad')]"),
        num_sec=20,
        message="wait for a CFME page appear",
        delay=0.5
    )
Пример #4
0
def test_services_request_direct_url(generated_request):
    """Go to the request page, save the url and try to access it directly."""
    assert requests.go_to_request(
        generated_request), "could not find the request!"
    request_url = sel.current_url()
    sel.get(sel.base_url())  # I need to flip it with something different here
    sel.get(request_url)  # Ok, direct access now.
    wait_for(
        lambda: sel.is_displayed("//body[contains(@onload, 'miqOnLoad')]"),
        num_sec=20,
        message="wait for a CFME page appear",
        delay=0.5)
Пример #5
0
def test_breadcrumbs(provider, soft_assert):

    for dataset in DATA_SETS:

        if current_version() < '5.7' and dataset.obj == Template:
            continue

        rows = navigate_and_get_rows(provider, dataset.obj, 1)
        if not rows:
            pytest.skip(
                'Could not test breadcrums: No records found in {}\'s table'.
                format(dataset.obj.__name__))
        row = rows[-1]
        instance_name = row[2].text
        sel.click(row)

        breadcrumb_elements = breadcrumbs()
        soft_assert(
            breadcrumb_elements,
            'Breadcrumbs not found in {} {} summary page'.format(
                dataset.obj.__name__, instance_name))
        bread_names_2_element = {
            sel.text_sane(b): b
            for b in breadcrumb_elements
        }

        try:
            breadcrumb_element = soft_get(bread_names_2_element,
                                          dataset.obj_base_name,
                                          dict_=True)
        except:
            soft_assert(
                False,
                'Could not find breadcrumb "{}" in {} {} summary page. breadcrumbs: {}'
                .format(dataset.obj_base_name, bread_names_2_element.keys(),
                        dataset.obj.__name__, instance_name))

        breadcrumb_name = sel.text_sane(breadcrumb_element)
        sel.click(breadcrumb_element)

        # We verify the location as following since we want to prevent from name convention errors
        soft_assert(
            dataset.obj_base_name in summary_title().lower(),
            'Breadcrumb link "{}" in {} {} page should navigate to '
            '{}s main page. navigated instead to: {}'.format(
                breadcrumb_name, dataset.obj.__name__, instance_name,
                dataset.obj.__name__, sel.current_url()))
Пример #6
0
def test_services_request_direct_url(generated_request):
    """Go to the request page, save the url and try to access it directly."""
    assert requests.go_to_request(
        generated_request), "could not find the request!"
    request_url = sel.current_url()
    sel.get(env["base_url"])  # I need to flip it with something different here
    sel.get(request_url)  # Ok, direct access now.
    # This is a bit tricky. We have to wait IF the blank page appeared, because checking
    # if we are STILL IN CFME is unreliable as the transition is not guarded by JS or stuff.
    # btw. when the on_cfme_page returns true because of being on login screen, it will work.
    # After logging in, user is redirected for a correct link. Tested.
    try:
        wait_for(lambda: not sel.on_cfme_page(),
                 num_sec=20,
                 message="wait for blank page appear")
        pytest.fail("Blank screen appeared!")
    except TimedOutError:
        pass  # Success!
Пример #7
0
def test_services_request_direct_url(generated_request):
    """Go to the request page, save the url and try to access it directly."""
    assert requests.go_to_request(generated_request), "could not find the request!"
    request_url = sel.current_url()
    sel.get(env["base_url"])    # I need to flip it with something different here
    sel.get(request_url)        # Ok, direct access now.
    # This is a bit tricky. We have to wait IF the blank page appeared, because checking
    # if we are STILL IN CFME is unreliable as the transition is not guarded by JS or stuff.
    # btw. when the on_cfme_page returns true because of being on login screen, it will work.
    # After logging in, user is redirected for a correct link. Tested.
    try:
        wait_for(
            lambda: not sel.on_cfme_page(),
            num_sec=20,
            message="wait for blank page appear"
        )
        pytest.fail("Blank screen appeared!")
    except TimedOutError:
        pass  # Success!
Пример #8
0
def test_breadcrumbs(provider, soft_assert):

    for dataset in DATA_SETS:

        if current_version() < '5.7' and dataset.obj == Template:
            continue

        rows = navigate_and_get_rows(provider, dataset.obj, 1)
        if not rows:
            pytest.skip('Could not test breadcrums: No records found in {}\'s table'
                        .format(dataset.obj.__name__))
        row = rows[-1]
        instance_name = row[2].text
        sel.click(row)

        breadcrumb_elements = breadcrumbs()
        soft_assert(breadcrumb_elements,
                    'Breadcrumbs not found in {} {} summary page'
                    .format(dataset.obj.__name__, instance_name))
        bread_names_2_element = {sel.text_sane(b): b for b in breadcrumb_elements}

        try:
            breadcrumb_element = soft_get(bread_names_2_element,
                                          dataset.obj_base_name, dict_=True)
        except:
            soft_assert(False,
                'Could not find breadcrumb "{}" in {} {} summary page. breadcrumbs: {}'
                .format(dataset.obj_base_name, bread_names_2_element.keys(),
                        dataset.obj.__name__, instance_name))

        breadcrumb_name = sel.text_sane(breadcrumb_element)
        sel.click(breadcrumb_element)

        # We verify the location as following since we want to prevent from name convention errors
        soft_assert(dataset.obj_base_name in summary_title().lower(),
            'Breadcrumb link "{}" in {} {} page should navigate to '
            '{}s main page. navigated instead to: {}'
            .format(breadcrumb_name, dataset.obj.__name__,
                    instance_name, dataset.obj.__name__,
                    sel.current_url()))
Пример #9
0
def get_ip_address():
    """Returns an IP address of the appliance
    """
    return urlparse(sel.current_url()).netloc
Пример #10
0
def get_ip_address():
    """Returns an IP address of the appliance
    """
    return urlparse(sel.current_url()).netloc