Exemplo n.º 1
0
 def load(self):
     self._keys = []
     key_values = []
     if sel.is_displayed(self.MULTIKEY_LOC, root=self._entry):
         # WE cannot process this kind of table yet.
         return
     for row in sel.elements(self.ROWS, root=self._entry):
         tds = sel.elements('./td', root=row)
         key = tds[0]
         klass = sel.get_attribute(key, 'class')
         if klass and 'label' in klass:
             # Ordinary field
             key_id = attributize_string(sel.text_sane(key))
             value = tuple(tds[1:])
             try:
                 rowspan = int(sel.get_attribute(key, 'rowspan'))
             except (ValueError, TypeError):
                 rowspan = None
             if rowspan:
                 key_values.append((key, key_id, [value]))
             else:
                 key_values.append((key, key_id, value))
         else:
             # value of last key_values should be extended
             key_values[-1][2].append(tuple(tds))
     for key, key_id, value in key_values:
         value_object = process_field(value)
         setattr(self, key_id, value_object)
         self._keys.append(key_id)
Exemplo n.º 2
0
def get_all_vms(do_not_navigate=False):
    """Returns list of all vms"""
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    vms = set([])

    # This is really stupid, but I cannot come up with better getting of the attributes :(
    if not paginator.page_controls_exist():
        for title in sel.elements(QUADICON_TITLE_LOCATOR):
            title_value = sel.get_attribute(title, "title")
            if not title_value:
                title_value = sel.get_attribute(title, "data-original-title")
            vms.add(title_value)
        return vms

    paginator.results_per_page(1000)
    for page in paginator.pages():
        try:
            for page in paginator.pages():
                for title in sel.elements(QUADICON_TITLE_LOCATOR):
                    title_value = sel.get_attribute(title, "title")
                    if not title_value:
                        title_value = sel.get_attribute(
                            title, "data-original-title")
                    vms.add(title_value)
        except sel.NoSuchElementException:
            pass
    return vms
Exemplo n.º 3
0
def get_all_vms(do_not_navigate=False):
    """Returns list of all vms"""
    if not do_not_navigate:
        sel.force_navigate('infra_vms')
    vms = set([])

    # This is really stupid, but I cannot come up with better getting of the attributes :(
    if not paginator.page_controls_exist():
        for title in sel.elements(QUADICON_TITLE_LOCATOR):
            title_value = sel.get_attribute(title, "title")
            if not title_value:
                title_value = sel.get_attribute(title, "data-original-title")
            vms.add(title_value)
        return vms

    paginator.results_per_page(1000)
    for page in paginator.pages():
        try:
            for page in paginator.pages():
                for title in sel.elements(QUADICON_TITLE_LOCATOR):
                    title_value = sel.get_attribute(title, "title")
                    if not title_value:
                        title_value = sel.get_attribute(title, "data-original-title")
                    vms.add(title_value)
        except sel.NoSuchElementException:
            pass
    return vms
Exemplo n.º 4
0
 def load(self):
     self._keys = []
     key_values = []
     for row in sel.elements(self.ROWS, root=self._entry):
         tds = sel.elements('./td', root=row)
         key = tds[0]
         klass = sel.get_attribute(key, 'class')
         if klass and 'label' in klass:
             # Ordinary field
             key_id = attributize_string(sel.text_sane(key))
             value = tuple(tds[1:])
             try:
                 rowspan = int(sel.get_attribute(key, 'rowspan'))
             except (ValueError, TypeError):
                 rowspan = None
             if rowspan:
                 key_values.append((key, key_id, [value]))
             else:
                 key_values.append((key, key_id, value))
         else:
             # value of last key_values should be extended
             key_values[-1][2].append(tuple(tds))
     for key, key_id, value in key_values:
         value_object = process_field(value)
         setattr(self, key_id, value_object)
         self._keys.append(key_id)
Exemplo n.º 5
0
    def _reload(self):
        self._legends = []
        self._elements = []
        self._lines = []
        self.search_box = TopologySearchBox()
        self.display_names = TopologyDisplayNames()
        # load elements
        # we have to wait few seconds, initial few seconds elements are moving
        if len(sel.elements(self.ELEMENTS)) > 0:
            self._el_ref = TopologyElement(o=self, element=sel.elements(self.ELEMENTS)[-1])
            wait_for(lambda: self._is_el_movement_stopped(), delay=2, num_sec=30)

            for element in sel.elements(self.ELEMENTS):
                self._elements.append(TopologyElement(o=self, element=element))
            # load lines
            for line in sel.elements(self.LINES):
                self._lines.append(TopologyLine(element=line))
        # load legends
        # remove old legends
        for legend_id in self._legends:
            try:
                delattr(self, legend_id)
            except AttributeError:
                pass
        # load available legends
        for legend in sel.elements(self.LEGENDS):
            legend_text = sel.text_sane(legend.find_element_by_tag_name('label'))
            legend_id = attributize_string(legend_text.strip())
            legend_object = TopologyLegend(name=legend_text, element=legend)
            setattr(self, legend_id, legend_object)
            self._legends.append(legend_id)
Exemplo n.º 6
0
 def is_on_chart_page(self):
     """Returns True we we are in detailed chart page, otherwise False"""
     if len(sel.text_sane(sel.elements(CHARTS))) == 0:
         return False
     if sel.text_sane(sel.element(CHARTS).find_element_by_tag_name('h2')) == self.name \
             and len(sel.elements(
                 "//table[contains(@class, 'table')]//th[normalize-space(.)='Date/Time']")) == 1:
         return True
     return False
Exemplo n.º 7
0
 def is_on_chart_page(self):
     """Returns True we we are in detailed chart page, otherwise False"""
     if len(sel.text_sane(sel.elements(CHARTS))) == 0:
         return False
     if sel.text_sane(sel.element(CHARTS).find_element_by_tag_name('h2')) == self.name \
             and len(sel.elements(
                 "//table[contains(@class, 'table')]//th[normalize-space(.)='Date/Time']")) == 1:
         return True
     return False
Exemplo n.º 8
0
    def reload_elements(self):
        self._elements = []
        self._lines = []
        if len(sel.elements(self.ELEMENTS)) > 0:
            self._el_ref = TopologyElement(o=self, element=sel.elements(self.ELEMENTS)[-1])
            wait_for(lambda: self._is_el_movement_stopped(), delay=2, num_sec=30)

            for element in sel.elements(self.ELEMENTS):
                self._elements.append(TopologyElement(o=self, element=element))
            # load lines
            for line in sel.elements(self.LINES):
                self._lines.append(TopologyLine(element=line))
Exemplo n.º 9
0
def _process_user_filling(fill_callback, cancel_on_user_filling=False):
    """This function handles answering CFME's requests on user input.

    A `fill_callback` function is passed. If the box with user input appears, all requested
    inputs are gathered and iterated over. On each element the `fill_callback` function is called
    with 2 parameters: text which precedes the element itself to do matching, and the element.

    This function does not check return status after `fill_callback` call.

    Args:
        fill_callback: The function to be called on each user input.
    """
    if sel.is_displayed(search_box.quick_search_box):  # That is the one with user inputs
        if fill_callback is None:
            raise Exception("User should have provided a callback function!")
        if isinstance(fill_callback, dict):
            fill_callback = partial(_answering_function, fill_callback)
        for input in sel.elements(
                "//fieldset/*[contains(@id, 'value_')]",
                root=sel.element(search_box.quick_search_box)):
            fill_callback(  # Let the func fill it
                sel.text(input.find_element_by_xpath("..")),    # Parent element's text
                input  # The form element
            )
        if cancel_on_user_filling:
            sel.click(search_box.userinput_cancel_button)
        else:
            sel.click(search_box.userinput_apply_filter_button)
Exemplo n.º 10
0
def wait_for_request(cells, partial_check=False):
    """helper function checks if a request is complete

    After finding the request's row using the ``cells`` argument, this will wait for a request to
    reach the 'Finished' state and return it. In the event of an 'Error' state, it will raise an
    AssertionError, for use with ``pytest.raises``, if desired.

    Args:
        cells: A dict of cells use to identify the request row to inspect in the
            :py:attr:`request_list` Table. See :py:meth:`cfme.web_ui.Table.find_rows_by_cells`
            for more.

    Usage:

        # Filter on the "Description" column
        description = 'Provision from [%s] to [%s]' % (template_name, vm_name)
        cells = {'Description': description}

        # Filter on the "Request ID" column
        # Text must match exactly, you can use "{:,}".format(request_id) to add commas if needed.
        request_id = '{:,}'.format(1000000000001)  # Becomes '1,000,000,000,001', as in the table
        cells = {'Request ID': request_id}

        # However you construct the cells dict, pass it to wait_for_request
        # Provisioning requests often take more than 5 minutes but less than 10.
        wait_for(wait_for_request, [cells], num_sec=600)

    Raises:
        AssertionError: if the matched request has status 'Error'
        RequestException: if multiple matching requests were found

    Returns:
         The matching :py:class:`cfme.web_ui.Table.Row` if found, ``False`` otherwise.
    """
    for page in paginator.pages():
        if sel.elements(request_list._header_loc) and not sel.is_displayed(request_list):
            # The table exists but it is hidden - no cells
            return False
        results = request_list.find_rows_by_cells(cells, partial_check)
        if len(results) == 0:
            # row not on this page, assume it has yet to appear
            continue
        elif len(results) > 1:
            raise RequestException(
                'Multiple requests with matching content found - be more specific!'
            )
        else:
            # found the row!
            row = results[0]
            logger.debug(' Request Message: %s' % row.last_message.text)
            break
    else:
        # Request not found at all, can't continue
        return False

    assert row.status.text != 'Error'
    if row.request_state.text == 'Finished':
        return row
    else:
        return False
Exemplo n.º 11
0
 def all(cls):
     """Returns objects with all Widgets currently present."""
     sel.force_navigate('dashboard')
     result = []
     for el in sel.elements(cls._all):
         result.append(cls(sel.get_attribute(el, "id")))
     return result
Exemplo n.º 12
0
 def all(cls):
     """Returns objects with all Widgets currently present."""
     navigate_to(Server, 'Dashboard')
     result = []
     for el in sel.elements(cls._all):
         result.append(cls(sel.get_attribute(el, "id")))
     return result
Exemplo n.º 13
0
def visible_toplevel_tabs():
    menu_names = []
    ele = 'li/a[2]'

    for menu_elem in sel.elements(ele, root=toplevel_tabs_loc):
        menu_names.append(sel.text(menu_elem))
    return menu_names
Exemplo n.º 14
0
 def all(cls):
     """For debugging purposes"""
     return [
         cls(sel.get_attribute(x, "id"))
         for x
         in sel.elements("//td[contains(@id, 'pivotcalc_id_')]")
     ]
Exemplo n.º 15
0
 def selected_items(self):
     self._close_combo()
     return [
         sel.text(item).encode("utf-8")
         for item in sel.elements(self._selected,
                                  root=sel.element(self._root_loc))
     ]
Exemplo n.º 16
0
    def reload_elements(self):
        self._elements = []
        self._lines = []
        if len(sel.elements(self.ELEMENTS)) > 0:
            self._el_ref = TopologyElement(o=self,
                                           element=sel.elements(
                                               self.ELEMENTS)[-1])
            wait_for(lambda: self._is_el_movement_stopped(),
                     delay=2,
                     num_sec=30)

            for element in sel.elements(self.ELEMENTS):
                self._elements.append(TopologyElement(o=self, element=element))
            # load lines
            for line in sel.elements(self.LINES):
                self._lines.append(TopologyLine(element=line))
Exemplo n.º 17
0
def visible_toplevel_tabs():
    menu_names = []
    ele = 'li/a[2]'

    for menu_elem in sel.elements(ele, root=toplevel_tabs_loc):
        menu_names.append(sel.text(menu_elem))
    return menu_names
Exemplo n.º 18
0
 def headers(cls):
     navigate_to(MiddlewareDomain, 'All')
     headers = [
         sel.text(hdr).encode("utf-8")
         for hdr in sel.elements("//thead/tr/th") if hdr.text
     ]
     return headers
Exemplo n.º 19
0
 def selected_items(self):
     self._close_combo()
     return [
         sel.text(item).encode("utf-8")
         for item
         in sel.elements(self._selected, root=sel.element(self._root_loc))
     ]
Exemplo n.º 20
0
 def _get_box(self):
     """Caching of the opened box"""
     if getattr(self, "_box_id", None) is None:
         self._open_box()
         for box in sel.elements(self._box):
             try:
                 sel.move_to_element(box)
                 if sel.is_displayed(box):
                     self._box_id = box.id
                     return box
             except sel.NoSuchElementException:
                 pass
         else:
             raise Exception("Could not open the box!")
     else:
         el = WebElement(sel.browser(), self._box_id)
         try:
             el.tag_name
             if not sel.is_displayed(el):
                 raise NotDisplayedException()
             return el
         except (StaleElementReferenceException, NoSuchElementException,
                 NotDisplayedException):
             del self._box_id
             return self._get_box()
Exemplo n.º 21
0
 def headers(cls):
     sel.force_navigate('middleware_servers')
     headers = [
         sel.text(hdr).encode("utf-8")
         for hdr in sel.elements("//thead/tr/th") if hdr.text
     ]
     return headers
Exemplo n.º 22
0
def test_perf_ui_infra_resource_pools(ui_worker_pid, soft_assert):
    pages, prod_tail = standup_perf_ui(ui_worker_pid, soft_assert)

    nav_limit = 0
    if 'resource_pools' in perf_tests['ui']['page_check']['infrastructure']:
        nav_limit = perf_tests['ui']['page_check']['infrastructure'][
            'resource_pools']

    pages.extend(
        analyze_page_stat(
            perf_click(ui_worker_pid, prod_tail, True, sel.force_navigate,
                       'infrastructure_resource_pools'), soft_assert))

    resource_pools = set([])
    for page in paginator.pages():
        for title in sel.elements(
                "//div[@id='quadicon']/../../../tr/td/a[contains(@href,"
                "'resource_pool/show')]"):
            resource_pools.add(sel.get_attribute(title, "title"))

    acc_bars = ['Properties', 'Relationships']

    pages.extend(
        navigate_quadicons(resource_pools, 'resource_pool',
                           'infrastructure_resource_pools', nav_limit,
                           ui_worker_pid, prod_tail, soft_assert, acc_bars))

    pages_to_csv(pages, 'perf_ui_infra_resource_pools.csv')
    pages_to_statistics_csv(pages, resource_pool_filters, 'ui-statistics.csv')
Exemplo n.º 23
0
 def headers(cls, domain):
     _get_server_groups_page(domain=domain)
     headers = [
         sel.text(hdr).encode("utf-8")
         for hdr in sel.elements("//thead/tr/th") if hdr.text
     ]
     return headers
Exemplo n.º 24
0
def _process_user_filling(fill_callback, cancel_on_user_filling=False):
    """This function handles answering CFME's requests on user input.

    A `fill_callback` function is passed. If the box with user input appears, all requested
    inputs are gathered and iterated over. On each element the `fill_callback` function is called
    with 2 parameters: text which precedes the element itself to do matching, and the element.

    This function does not check return status after `fill_callback` call.

    Args:
        fill_callback: The function to be called on each user input.
    """
    if sel.is_displayed(
            search_box.quick_search_box):  # That is the one with user inputs
        if fill_callback is None:
            raise Exception("User should have provided a callback function!")
        if isinstance(fill_callback, dict):
            fill_callback = partial(_answering_function, fill_callback)
        for input in sel.elements("//fieldset/*[contains(@id, 'value_')]",
                                  root=sel.element(
                                      search_box.quick_search_box)):
            fill_callback(  # Let the func fill it
                sel.text(input.find_element_by_xpath(
                    "..")),  # Parent element's text
                input  # The form element
            )
        if cancel_on_user_filling:
            sel.click(search_box.userinput_cancel_button)
        else:
            sel.click(search_box.userinput_apply_filter_button)
Exemplo n.º 25
0
 def all(cls):
     """For debugging purposes"""
     return [
         cls(sel.get_attribute(x, "id"))
         for x
         in sel.elements("//td[contains(@id, 'pivotcalc_id_')]")
     ]
Exemplo n.º 26
0
def visible_toplevel_tabs():
    menu_names = []
    ele = version.pick({
        "5.4": 'li/a[2]',
        version.LOWEST: 'li/a'})
    for menu_elem in sel.elements(ele, root=Loc.toplevel_tabs_loc):
        menu_names.append(sel.text(menu_elem))
    return menu_names
Exemplo n.º 27
0
def visible_toplevel_tabs():
    menu_names = []
    ele = version.pick({
        "5.4": 'li/a[2]',
        version.LOWEST: 'li/a'})
    for menu_elem in sel.elements(ele, root=Loc.toplevel_tabs_loc):
        menu_names.append(sel.text(menu_elem))
    return menu_names
Exemplo n.º 28
0
def get_tags(tag="My Company Tags"):
    tags = []
    for row in sel.elements(
            "//*[(self::th or self::td) and normalize-space(.)={}]/../.."
            "//td[img[contains(@src, 'smarttag')]]".format(
                quoteattr(tag))):
        tags.append(sel.text(row).strip())
    return tags
Exemplo n.º 29
0
 def opened_boxes_ids(self):
     """Return ids of all opened boxes."""
     return [
         # it's like 's_3'
         int(sel.get_attribute(el, "id").rsplit("_", 1)[-1])
         for el in sel.elements("//div[@title='Drag this Shortcut to a new location']")
         if sel.is_displayed(el)
     ]
Exemplo n.º 30
0
def get_tags(tag="My Company Tags"):
    tags = []
    tagpath = "//*[(self::th or self::td) and normalize-space(.)={}]/../.."\
        "//td[img[contains(@src, 'smarttag')]]" if current_version() < '5.8'\
        else "//td[i[contains(@class, 'fa-tag')]]"
    for row in sel.elements(tagpath.format(quoteattr(tag))):
        tags.append(sel.text(row).strip())
    return tags
Exemplo n.º 31
0
    def _old_visible_toplevel_tabs(self):
        """Method returning the visible toplevel_tabs in 5.4"""
        menu_names = []
        ele = 'li/a[2]'

        for menu_elem in sel.elements(ele, root=self.toplevel_tabs_loc):
            menu_names.append(sel.text(menu_elem))
        return menu_names
Exemplo n.º 32
0
 def get_tags(self):
     navigate_to(self, 'Details')
     row = sel.elements(
         "//*[(self::th or self::td) and normalize-space(.)={}]/../.."
         "//td[img[contains(@src, 'smarttag')]]".format(
             quoteattr("My Company Tags")))
     company_tag = sel.text(row).strip()
     return company_tag
Exemplo n.º 33
0
def get_tags(tag="My Company Tags"):
    tags = []
    tagpath = "//*[(self::th or self::td) and normalize-space(.)={}]/../.."\
        "//td[img[contains(@src, 'smarttag')]]" if current_version() < '5.8'\
        else "//td[i[contains(@class, 'fa-tag')]]"
    for row in sel.elements(tagpath.format(quoteattr(tag))):
        tags.append(sel.text(row).strip())
    return tags
Exemplo n.º 34
0
    def _old_visible_toplevel_tabs(self):
        """Method returning the visible toplevel_tabs in 5.4"""
        menu_names = []
        ele = 'li/a[2]'

        for menu_elem in sel.elements(ele, root=self.toplevel_tabs_loc):
            menu_names.append(sel.text(menu_elem))
        return menu_names
Exemplo n.º 35
0
 def get_tags(self):
     sel.force_navigate('clouds_stack', context={'stack': self})
     row = sel.elements(
         "//*[(self::th or self::td) and normalize-space(.)={}]/../.."
         "//td[img[contains(@src, 'smarttag')]]".format(
             quoteattr("My Company Tags")))
     company_tag = sel.text(row).strip()
     return company_tag
Exemplo n.º 36
0
def get_all_tabs():
    """ Return list of all tabs present.

    Returns: :py:class:`list` of :py:class:`str` Displayed names.
    """
    return [
        opt.text.strip().encode("utf-8")
        for opt in sel.elements(".//li/a", root=_root())
    ]
Exemplo n.º 37
0
 def data(self):
     result = []
     for row in sel.elements("./div/table/tbody/tr/td", root=self.root):
         # Regular expressions? Boring.
         desc, date = sel.text(row).encode("utf-8").strip().rsplit("\n", 1)
         date = date.split(":", 1)[-1].strip()
         date = parsetime.from_iso_with_utc(date)
         result.append((desc, date))
     return result
Exemplo n.º 38
0
 def opened_boxes_ids(self):
     """Return ids of all opened boxes."""
     return [
         # it's like 's_3'
         int(sel.get_attribute(el, "id").rsplit("_", 1)[-1])
         for el in sel.elements(
             "//div[@title='Drag this Shortcut to a new location']")
         if sel.is_displayed(el)
     ]
Exemplo n.º 39
0
 def add(self, subfolder):
     self.add_subfolder()
     wait_for(lambda: self.selected_field_element is not None, num_sec=5, delay=0.1)
     sel.double_click(self.selected_field_element)
     input = wait_for(
         lambda: sel.elements("./input", root=self.selected_field_element),
         num_sec=5, delay=0.1, fail_condition=[])[0][0]
     sel.set_text(input, subfolder)
     sel.send_keys(input, Keys.RETURN)
Exemplo n.º 40
0
 def add(self, subfolder):
     self.add_subfolder()
     wait_for(lambda: self.selected_field_element is not None, num_sec=5, delay=0.1)
     sel.double_click(self.selected_field_element)
     input = wait_for(
         lambda: sel.elements("./input", root=self.selected_field_element),
         num_sec=5, delay=0.1, fail_condition=[])[0][0]
     sel.set_text(input, subfolder)
     sel.send_keys(input, Keys.RETURN)
Exemplo n.º 41
0
def test_group_edit_tag():
    group = new_group()
    group.create()
    group.edit_tags("Cost Center *", "Cost Center 001")
    row = sel.elements("//*[(self::th or self::td) and normalize-space(.)={}]/../.."
        "//td[img[contains(@src, 'smarttag')]]".format(quoteattr("My Company Tags")))
    tag = sel.text(row).strip()
    assert tag == "Cost Center: Cost Center 001", "Group edit tag failed"
    group.delete()
Exemplo n.º 42
0
 def data(self):
     result = []
     for row in sel.elements("./div/table/tbody/tr/td", root=self.root):
         # Regular expressions? Boring.
         desc, date = sel.text(row).encode("utf-8").strip().rsplit("\n", 1)
         date = date.split(":", 1)[-1].strip()
         date = parsetime.from_iso_with_utc(date)
         result.append((desc, date))
     return result
Exemplo n.º 43
0
 def get_tags(self, tag="My Company Tags"):
     """Returns all tags that are associated with this VM"""
     self.load_details(refresh=True)
     tags = []
     for row in sel.elements(
             "//*[(self::th or self::td) and normalize-space(.)={}]/../.."
             "//td[img[contains(@src, 'smarttag')]]".format(
                 quoteattr(tag))):
         tags.append(sel.text(row).strip())
     return tags
Exemplo n.º 44
0
 def get_tags(self, tag="My Company Tags"):
     """Returns all tags that are associated with this VM"""
     self.load_details(refresh=True)
     tags = []
     for row in sel.elements(
             "//*[(self::th or self::td) and normalize-space(.)={}]/../.."
             "//td[img[contains(@src, 'smarttag')]]".format(
                 quoteattr(tag))):
         tags.append(sel.text(row).strip())
     return tags
Exemplo n.º 45
0
def get_active_links(name):
    """ Returns all active links in a section specified by name

    Args:
        name: Name of the section
    """
    link_root = _content_element(name)
    link_loc = './/div[@class="panecontent"]//a[@title]/img/..'
    active_els = sel.elements(link_loc, root=link_root)
    return [ListAccordionLink(el.get_attribute("title"), link_root) for el in active_els]
Exemplo n.º 46
0
def get_all_hosts(do_not_navigate=False):
    """Returns list of all hosts"""
    if not do_not_navigate:
        navigate_to(Host, 'All')
    hosts = set([])
    for page in paginator.pages():
        for title in sel.elements(
                "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'host/show')]"):
            hosts.add(sel.get_attribute(title, "title"))
    return hosts
Exemplo n.º 47
0
def get_all_hosts(do_not_navigate=False):
    """Returns list of all hosts"""
    if not do_not_navigate:
        sel.force_navigate('infrastructure_hosts')
    hosts = set([])
    for page in paginator.pages():
        for title in sel.elements(
                "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'host/show')]"):
            hosts.add(sel.get_attribute(title, "title"))
    return hosts
Exemplo n.º 48
0
def get_all_clusters(do_not_navigate=False):
    """Returns list of all clusters"""
    if not do_not_navigate:
        sel.force_navigate('infrastructure_clusters')
    clusters = set([])
    for page in paginator.pages():
        for title in sel.elements(
                "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'cluster/show')]"):
            clusters.add(sel.get_attribute(title, "title"))
    return clusters
Exemplo n.º 49
0
def old_select(root, sub=None, invokes_alert=False):
    """ Clicks on a button by calling the dhtmlx toolbar callEvent.

    Args:
        root: The root button's name as a string.
        sub: The sub button's name as a string. (optional)
        invokes_alert: If ``True``, then the behaviour is little bit different. After the last
            click, no ajax wait and no move away is done to be able to operate the alert that
            appears after click afterwards. Defaults to ``False``.
    Returns: ``True`` if everything went smoothly
    Raises: :py:class:`cfme.exceptions.ToolbarOptionGreyedOrUnavailable`
    """
    # wait for ajax on select to prevent pickup up a toolbar button in the middle of a page change
    sel.wait_for_ajax()
    if isinstance(root, dict):
        root = version.pick(root)
    if sub is not None and isinstance(sub, dict):
        sub = version.pick(sub)

    root_obj = version.pick({
        '5.4': 'miq_toolbars',
        '5.5.0.7': 'ManageIQ.toolbars'
    })

    if sub:
        search = sub_loc(sub)
    else:
        search = root_loc(root)

    eles = sel.elements(search)

    for ele in eles:
        idd = sel.get_attribute(ele, 'idd')
        if idd:
            break
    else:
        raise ToolbarOptionGreyedOrUnavailable(
            "Toolbar button {}/{} is greyed or unavailable!".format(root, sub))

    buttons = sel.execute_script('return {}'.format(root_obj))
    tb_name = None
    for tb_key, tb_obj in buttons.iteritems():
        for btn_key, btn_obj in tb_obj['buttons'].iteritems():
            if btn_obj['name'] == idd:
                tb_name = tb_key
    if not tb_name:
        raise ToolbarOptionGreyedOrUnavailable(
            "Toolbar button {}/{} is greyed or unavailable!".format(root, sub))

    sel.execute_script("{}['{}']['obj'].callEvent('onClick', ['{}'])".format(
        root_obj, tb_name, idd))

    if not invokes_alert:
        sel.wait_for_ajax()
    return True
Exemplo n.º 50
0
    def form(self):
        """Returns Form filled with fields. Scraps the webpage to determine the fields.

        Requires to be on the page
        """
        names = []
        for cell in sel.elements(self.fields):
            # The received text is something like u'  (blabla)' so we extract 'blabla'
            sel.move_to_element(cell)  # This is required in order to correctly read the content
            names.append(re.sub(r"^[^(]*\(([^)]+)\)[^)]*$", "\\1", sel.text(cell).encode("utf-8")))
        return Form(fields=[(name, InstanceFieldsRow(i)) for i, name in enumerate(names)])
Exemplo n.º 51
0
    def get_datastores(self):
        """ Gets list of all datastores used by this host"""
        sel.force_navigate('infrastructure_host', context={'host': self})
        list_acc.select('Relationships', 'Show all Datastores')

        datastores = set([])
        for page in paginator.pages():
            for title in sel.elements(
                    "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'storage/show')]"):
                datastores.add(sel.get_attribute(title, "title"))
        return datastores
Exemplo n.º 52
0
def get_all_providers(do_not_navigate=False):
    """Returns list of all providers"""
    if not do_not_navigate:
        sel.force_navigate('clouds_providers')
    providers = set([])
    link_marker = "ems_cloud"
    for page in paginator.pages():
        for title in sel.elements("//div[@id='quadicon']/../../../tr/td/a[contains(@href,"
                "'{}/show')]".format(link_marker)):
            providers.add(sel.get_attribute(title, "title"))
    return providers
Exemplo n.º 53
0
def get_active_links(name):
    """ Returns all active links in a section specified by name

    Args:
        name: Name of the section
    """
    link_root = _content_element(name)
    link_loc = './/div[@class="panecontent"]//a[@title and not(child::img)]|'\
               './li[not(contains(@class, "disabled"))]/a'
    active_els = sel.elements(link_loc, root=link_root)
    return [ListAccordionLink(el.get_attribute("title"), link_root) for el in active_els]
Exemplo n.º 54
0
def get_all_providers(do_not_navigate=False):
    """Returns list of all providers"""
    if not do_not_navigate:
        navigate_to(CloudProvider, 'All')
    providers = set([])
    link_marker = "ems_cloud"
    for page in paginator.pages():
        for title in sel.elements("//div[@id='quadicon']/../../../tr/td/a[contains(@href,"
                "'{}/show')]".format(link_marker)):
            providers.add(sel.get_attribute(title, "title"))
    return providers
Exemplo n.º 55
0
def test_group_remove_tag():
    group = new_group()
    group.create()
    sel.force_navigate("cfg_accesscontrol_group_ed", context={"group": group})
    row = sel.elements("//*[(self::th or self::td) and normalize-space(.)={}]/../.."
        "//td[img[contains(@src, 'smarttag')]]".format(quoteattr("My Company Tags")))
    tag = sel.text(row).strip()
    group.edit_tags("Department", "Engineering")
    group.remove_tag("Department", "Engineering")
    assert tag != "Department: Engineering", "Remove Group tag failed"
    group.delete()
Exemplo n.º 56
0
 def proc_node(loc, c=0, prev_node=None):
     if not prev_node:
         prev_node = []
     for el in sel.elements(loc + self.ANY_LEV):
         sel.move_to_element(el)
         new_loc = loc + self.NAMED_LEV.format(el.text)
         nn = prev_node[:]
         nn.append(el.text)
         proc_node(new_loc, c + 1, nn)
     else:
         nodes.append(prev_node)
Exemplo n.º 57
0
 def proc_node(loc, c=0, prev_node=None):
     if not prev_node:
         prev_node = []
     for el in sel.elements(loc + self.ANY_LEV):
         sel.move_to_element(el)
         new_loc = loc + self.NAMED_LEV.format(el.text)
         nn = prev_node[:]
         nn.append(el.text)
         proc_node(new_loc, c + 1, nn)
     else:
         nodes.append(prev_node)
Exemplo n.º 58
0
    def get_datastores(self):
        """ Gets list of all datastores used by this host"""
        sel.force_navigate('infrastructure_host', context={'host': self})
        list_acc.select('Relationships', 'Datastores', by_title=False, partial=True)

        datastores = set([])
        for page in paginator.pages():
            for title in sel.elements(
                    "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'storage/show')]"):
                datastores.add(sel.get_attribute(title, "title"))
        return datastores
Exemplo n.º 59
0
def old_select(root, sub=None, invokes_alert=False):
    """ Clicks on a button by calling the dhtmlx toolbar callEvent.

    Args:
        root: The root button's name as a string.
        sub: The sub button's name as a string. (optional)
        invokes_alert: If ``True``, then the behaviour is little bit different. After the last
            click, no ajax wait and no move away is done to be able to operate the alert that
            appears after click afterwards. Defaults to ``False``.
    Returns: ``True`` if everything went smoothly
    Raises: :py:class:`cfme.exceptions.ToolbarOptionGreyedOrUnavailable`
    """
    # wait for ajax on select to prevent pickup up a toolbar button in the middle of a page change
    sel.wait_for_ajax()
    if isinstance(root, dict):
        root = version.pick(root)
    if sub is not None and isinstance(sub, dict):
        sub = version.pick(sub)

    root_obj = version.pick({'5.4': 'miq_toolbars',
        '5.5.0.7': 'ManageIQ.toolbars'})

    if sub:
        search = sub_loc(sub)
    else:
        search = root_loc(root)

    eles = sel.elements(search)

    for ele in eles:
        idd = sel.get_attribute(ele, 'idd')
        if idd:
            break
    else:
        raise ToolbarOptionGreyedOrUnavailable(
            "Toolbar button {}/{} is greyed or unavailable!".format(root, sub))

    buttons = sel.execute_script('return {}'.format(root_obj))
    tb_name = None
    for tb_key, tb_obj in buttons.iteritems():
        for btn_key, btn_obj in tb_obj['buttons'].iteritems():
            if btn_obj['name'] == idd:
                tb_name = tb_key
    if not tb_name:
        raise ToolbarOptionGreyedOrUnavailable(
            "Toolbar button {}/{} is greyed or unavailable!".format(root, sub))

    sel.execute_script(
        "{}['{}']['obj'].callEvent('onClick', ['{}'])".format(root_obj, tb_name, idd))

    if not invokes_alert:
        sel.wait_for_ajax()
    return True