Exemple #1
0
 def click_on_saved_reports(self):
     self.accordion.accordion_by_name("Saved Reports").click()
     self._wait_for_results_refresh()
     from cfme.web_ui import Tree
     tree = Tree("//tr[@title='All Saved Reports']/../..")
     tree.click_path("All Saved Reports")
     return VirtualIntelligence.SavedReportsSection(self.testsetup)
Exemple #2
0
def tree(name, *path):
    """Get underlying Tree() object. And eventually click path.

    If the accordion is not active, will be clicked.
    Attention! The object is 'live' so when it's obscured, it won't work!

    Usage:
        accordion.tree("Something").click_path("level 1", "level 2")
        accordion.tree("Something", "level 1", "level 2")  # is the same

    Args:
        *path: If specified, it will directly pass these parameters into click_path of Tree.
            Otherwise it returns the Tree object.
    """
    try:
        if not is_active(name):
            click(name)
    except AccordionItemNotFound:
        click(name)

    root_element = sel.element(locate(name))
    if sel.is_displayed(DYNATREE, root=root_element):
        # Dynatree detected
        tree = Tree(sel.element(DYNATREE, root=root_element))
    elif sel.is_displayed(TREEVIEW, root=root_element):
        # treeview detected
        el = sel.element(TREEVIEW, root=root_element)
        tree_id = sel.get_attribute(el, 'id')
        tree = BootstrapTreeview(tree_id)

    if path:
        return tree.click_path(*path)
    else:
        return tree
 def click_on_saved_reports(self):
     self.accordion.accordion_by_name("Saved Reports").click()
     self._wait_for_results_refresh()
     from cfme.web_ui import Tree
     tree = Tree("//tr[@title='All Saved Reports']/../..")
     tree.click_path("All Saved Reports")
     return VirtualIntelligence.SavedReportsSection(self.testsetup)
def tree(name, *path):
    """Get underlying Tree() object. And eventually click path.

    If the accordion is not active, will be clicked.
    Attention! The object is 'live' so when it's obscured, it won't work!

    Usage:
        accordion.tree("Something").click_path("level 1", "level 2")
        accordion.tree("Something", "level 1", "level 2")  # is the same

    Args:
        *path: If specified, it will directly pass these parameters into click_path of Tree.
            Otherwise it returns the Tree object.
    """
    click(name)
    tree = Tree(
        sel.first_from(
            # Current tree
            "../../div[contains(@class, 'dhxcont_global_content_area')]//"
            "ul[@class='dynatree-container']",
            # Legacy tree
            "../../div[contains(@class, 'dhxcont_global_content_area')]//"
            "div[@class='containerTableStyle']//table[not(ancestor::tr[contains(@style,'none')])]",
            root=sel.element(locate(name))
        )
    )
    if path:
        return tree.click_path(*path)
    else:
        return tree
Exemple #5
0
def tree(name, *path):
    """Get underlying Tree() object. And eventually click path.

    If the accordion is not active, will be clicked.
    Attention! The object is 'live' so when it's obscured, it won't work!

    Usage:
        accordion.tree("Something").click_path("level 1", "level 2")
        accordion.tree("Something", "level 1", "level 2")  # is the same

    Args:
        *path: If specified, it will directly pass these parameters into click_path of Tree.
            Otherwise it returns the Tree object.
    """
    try:
        if not is_active(name):
            click(name)
    except AccordionItemNotFound:
        click(name)
    el = sel.element(
        # | for only single query
        "|".join([
            # Current tree for 5.4 (still with dhx)
            "../../div[contains(@class, 'dhxcont_global_content_area')]//"
            "ul[@class='dynatree-container']",
            # Newer accordion tree
            "../../..//div[@class='panel-body']//ul[@class='dynatree-container']"]),
        root=sel.element(locate(name)))
    tree = Tree(el)
    if path:
        return tree.click_path(*path)
    else:
        return tree
Exemple #6
0
def test_shuffle_top_level(group, on_finish_default):
    # Shuffle the order
    with menus.manage_folder(group) as folder:
        order = shuffle(folder.fields)
        for item in reversed(order):
            folder.move_first(item)
    # Now go and read the tree
    pytest.sel.force_navigate("reports")
    tree = accordion.tree("Reports").read_contents()
    checked = Tree.flatten_level(Tree.browse(tree, "All Reports"))
    assert checked == order, "The order differs!"
 def reorder_elements(self, tab, box, *element_data):
     sel.force_navigate('service_dialog_edit', context={'dialog': self})
     if version.current_version() > "5.5":
         tree = accordion.tree("Dialog")
     else:
         tree = Tree("dialog_edit_treebox")
     tree.click_path(self.label, tab, box)
     list_ele = []
     for each_element in element_data:
         list_ele.append(each_element.get("ele_label"))
     ele_1 = self.element(list_ele[0])
     ele_2 = self.element(list_ele[1])
     sel.drag_and_drop(ele_1, ele_2)
     sel.click(form_buttons.save)
     flash.assert_no_errors()
Exemple #8
0
 def reorder_elements(self, tab, box, *element_data):
     sel.force_navigate('service_dialog_edit', context={'dialog': self})
     if version.current_version() > "5.5":
         tree = accordion.tree("Dialog")
     else:
         tree = Tree("dialog_edit_treebox")
     tree.click_path(self.label, tab, box)
     list_ele = []
     for each_element in element_data:
         list_ele.append(each_element.get("ele_label"))
     ele_1 = self.element(list_ele[0])
     ele_2 = self.element(list_ele[1])
     sel.drag_and_drop(ele_1, ele_2)
     sel.click(form_buttons.save)
     flash.assert_no_errors()
Exemple #9
0
def tree(name, *path):
    """Get underlying Tree() object. And eventually click path.

    If the accordion is not active, will be clicked.
    Attention! The object is 'live' so when it's obscured, it won't work!

    Usage:
        accordion.tree("Something").click_path("level 1", "level 2")
        accordion.tree("Something", "level 1", "level 2")  # is the same

    Args:
        *path: If specified, it will directly pass these parameters into click_path of Tree.
            Otherwise it returns the Tree object.
    """
    try:
        if not is_active(name):
            logger.debug(
                'Clicking accordion item %s because it is not active.', name)
            click(name)
    except AccordionItemNotFound:
        logger.debug(
            'Clicking accordion item %s because AccordionItemNotFound raised.',
            name)
        click(name)

    locator = locate(name)
    # Wait a bit for any of the trees to appear
    wait_for(lambda: sel.is_displayed(ANY_TREE, root=locator),
             quiet=True,
             silent_failure=True,
             delay=0.2,
             timeout=5)
    if sel.is_displayed(DYNATREE, root=locator):
        # Dynatree detected
        tree = Tree(sel.element(DYNATREE, root=locator))
    elif sel.is_displayed(TREEVIEW, root=locator):
        # treeview detected
        el = sel.element(TREEVIEW, root=locator)
        tree_id = sel.get_attribute(el, 'id')
        tree = BootstrapTreeview(tree_id)
    else:
        raise TypeError('None of the supported trees was detected.')

    if path:
        return tree.click_path(*path)
    else:
        return tree
 def update_element(self, second_element, element_data):
     navigate_to(self, 'Edit')
     if version.current_version() > "5.5":
         tree = accordion.tree("Dialog")
     else:
         tree = Tree("dialog_edit_treebox")
     tree.click_path(self.label, self.tab_label, self.box_label)
     self.add_element(second_element)
     list_ele = []
     list_ele.append(element_data.get("ele_label"))
     list_ele.append(second_element.get("ele_label"))
     tree.click_path(self.label, self.tab_label, self.box_label)
     ele_1 = self.element(list_ele[0])
     ele_2 = self.element(list_ele[1])
     sel.drag_and_drop(ele_1, ele_2)
     sel.click(form_buttons.save)
     flash.assert_no_errors()
Exemple #11
0
def test_shuffle_first_level(group, on_finish_default):
    # Find a folder
    pytest.sel.force_navigate("reports")
    tree = accordion.tree("Reports").read_contents()
    folders = Tree.browse(tree, "All Reports")
    # Select some folder that has at least 3 children
    folders = map(lambda item: item[0],
                filter(lambda item: isinstance(item[1], list) and len(item[1]) >= 3, folders))
    selected_folder = random.choice(folders)
    # Shuffle the order
    with menus.manage_folder(group, selected_folder) as folder:
        order = shuffle(folder.fields)
        for item in reversed(order):
            folder.move_first(item)
    # Now go and read the tree
    pytest.sel.force_navigate("reports")
    tree = accordion.tree("Reports").read_contents()
    checked = Tree.flatten_level(Tree.browse(tree, "All Reports", selected_folder))
    assert checked == order, "The order differs!"
def tree(name, *path):
    """Get underlying Tree() object. And eventually click path.

    If the accordion is not active, will be clicked.
    Attention! The object is 'live' so when it's obscured, it won't work!

    Usage:
        accordion.tree("Something").click_path("level 1", "level 2")
        accordion.tree("Something", "level 1", "level 2")  # is the same

    Args:
        *path: If specified, it will directly pass these parameters into click_path of Tree.
            Otherwise it returns the Tree object.
    """
    try:
        if not is_active(name):
            logger.debug('Clicking accordion item %s because it is not active.', name)
            click(name)
    except AccordionItemNotFound:
        logger.debug('Clicking accordion item %s because AccordionItemNotFound raised.', name)
        click(name)

    locator = locate(name)
    # Wait a bit for any of the trees to appear
    wait_for(
        lambda: sel.is_displayed(ANY_TREE, root=locator),
        quiet=True, silent_failure=True, delay=0.2, timeout=5)
    if sel.is_displayed(DYNATREE, root=locator):
        # Dynatree detected
        tree = Tree(sel.element(DYNATREE, root=locator))
    elif sel.is_displayed(TREEVIEW, root=locator):
        # treeview detected
        el = sel.element(TREEVIEW, root=locator)
        tree_id = sel.get_attribute(el, 'id')
        tree = BootstrapTreeview(tree_id)
    else:
        raise TypeError('None of the supported trees was detected.')

    if path:
        return tree.click_path(*path)
    else:
        return tree
 def update_element(self, second_element, element_data):
     navigate_to(self, 'Edit')
     if self.appliance.version > "5.5":
         tree = accordion.tree("Dialog")
     else:
         tree = Tree("dialog_edit_treebox")
     tree.click_path(self.label, self.tab_label, self.box_label)
     self.add_element(second_element)
     list_ele = []
     list_ele.append(element_data.get("ele_label"))
     list_ele.append(second_element.get("ele_label"))
     tree.click_path(self.label, self.tab_label, self.box_label)
     ele_1 = self.element(list_ele[0])
     ele_2 = self.element(list_ele[1])
     sel.drag_and_drop(ele_1, ele_2)
     sel.click(form_buttons.save)
     flash.assert_no_errors()
Exemple #14
0
 def update_element(self, second_element, element_data):
     sel.force_navigate('service_dialog_edit', context={'dialog': self})
     if version.current_version() > "5.5":
         tree = accordion.tree("Dialog")
     else:
         tree = Tree("dialog_edit_treebox")
     tree.click_path(self.label, self.tab_label, self.box_label)
     self.add_element(second_element)
     list_ele = []
     list_ele.append(element_data.get("ele_label"))
     list_ele.append(second_element.get("ele_label"))
     tree.click_path(self.label, self.tab_label, self.box_label)
     ele_1 = self.element(list_ele[0])
     ele_2 = self.element(list_ele[1])
     sel.drag_and_drop(ele_1, ele_2)
     sel.click(form_buttons.save)
     flash.assert_no_errors()
from utils.pretty import Pretty
from utils.update import Updateable

from widgetastic.utils import Fillable


accordion_tree = functools.partial(accordion.tree, "Service Dialogs")
cfg_btn = functools.partial(tb.select, "Configuration")
plus_btn = functools.partial(tb.select, "Add")
entry_table = Table({'5.6': "//div[@id='field_values_div']/form/table",
                     '5.5': "//div[@id='field_values_div']/form/fieldset/table"})
text_area_table = Table("//div[@id='dialog_field_div']/fieldset/table[@class='style1']")
text_area_table = Table({version.LOWEST: "//div[@id='dialog_field_div']/fieldset/table"
                        "[@class='style1']",
                    '5.5': "//div[@id='dialog_field_div']/div[@class='form-horizontal']"})
dynamic_tree = Tree("//div[@class='modal-content']/div/div/ul[@class='dynatree-container']")
bt_tree = BootstrapTreeview('automate_treebox')

label_form = Form(fields=[
    ('label', Input("label")),
    ('description_text', Input("description")),
    ('submit_button', Input("chkbx_submit")),
    ('cancel_button', Input("chkbx_cancel"))
])

tab_form = Form(fields=[
    ('tab_label', Input("tab_label")),
    ('tab_desc', Input("tab_description"))
])

box_form = Form(fields=[
Exemple #16
0
from utils import version
from utils.virtual_machines import deploy_template
from utils.log import logger
from utils.pretty import Pretty
from utils.update import Updateable
from utils.wait import wait_for


cfg_btn = partial(toolbar.select, 'Configuration')
pol_btn = partial(toolbar.select, 'Policy')
lcl_btn = partial(toolbar.select, 'Lifecycle')
mon_btn = partial(toolbar.select, 'Monitoring')
pwr_btn = partial(toolbar.select, 'Power')

visible_tree = Tree("//div[@class='dhxcont_global_content_area']"
                    "[not(contains(@style, 'display: none'))]/div/div/div"
                    "/ul[@class='dynatree-container']")

details_page = Region(infoblock_type='detail')

list_page = Region(title='Instances')

policy_page = Region(
    locators={
        'policy_tree': Tree('//div[@class="containerTableStyle"]/table')
    })

manage_policies_tree = CheckboxTree(
    {
        version.LOWEST: "//div[@id='treebox']/div/table",
        "5.3": "//div[@id='protect_treebox']/ul"
""" A model of Workloads page in CFME
"""

from cfme.web_ui import accordion, menu, Tree


visible_tree = Tree("//div[@class='dhxcont_global_content_area']"
                    "[not(contains(@style, 'display: none'))]/div/div/div"
                    "/ul[@class='dynatree-container']")

menu.nav.add_branch(
    "services_workloads",
    {
        "service_vms_instances":
        [
            lambda _: accordion.tree("VMs & Instances", "All VMs & Instances"),
            {
                "service_vms_instances_filter_folder":
                [
                    lambda ctx: visible_tree.click_path(ctx["folder_name"]),
                    {
                        "service_vms_instances_filter":
                        lambda ctx: visible_tree.click_path(ctx["filter_name"])
                    }
                ]
            }
        ],

        "service_templates_images":
        [
            lambda _: (accordion.tree("Templates & Images", "All Templates & Images")),
Exemple #18
0
from utils.api import rest_api
from utils.wait import wait_for

cfg_btn = partial(toolbar.select, 'Configuration')
pwr_btn = partial(toolbar.select, 'Power')

tree_inst_by_prov = partial(accordion.tree, "Instances by Provider")
tree_instances = partial(accordion.tree, "Instances")
tree_image_by_prov = partial(accordion.tree, "Images by Provider")
tree_images = partial(accordion.tree, "Images")

list_page = Region(title='Instances')

policy_page = Region(
    locators={
        'policy_tree': Tree('//div[@class="containerTableStyle"]/table')
    })

manage_policies_tree = CheckboxTree("//div[@id='protect_treebox']/ul")


@extend_nav
class clouds_instances:
    def clouds_instances_by_provider(_):
        tree_inst_by_prov("Instances by Provider")

    def clouds_instances_provider_branch(ctx):
        tree_inst_by_prov("Instances by Provider", ctx["provider_name"])

    def clouds_instance_obj(ctx):
        tree_inst_by_prov("Instances by Provider", ctx["provider_name"],
Exemple #19
0
from functools import partial

from selenium.webdriver.common.by import By

import cfme.web_ui.accordion as accordion
import cfme.web_ui.toolbar as tb
import cfme.fixtures.pytest_selenium as sel
from cfme.web_ui import Form, Select, Tree, fill, flash
from cfme.web_ui.menu import nav
from utils.update import Updateable
from utils.pretty import Pretty

rate_tree = Tree("//div[@id='cb_rates_treebox']/ul")
tb_select = partial(tb.select, "Configuration")
tb_select_new_chargeback = nav.fn(partial(tb_select, "Add a new Chargeback Rate"))
tb_select_edit_chargeback = nav.fn(partial(tb_select, "Edit this Chargeback Rate"))


class RateFormItem(Pretty):
    pretty_attrs = ['rate_loc', 'unit_select_loc']

    def __init__(self, rate_loc=None, unit_select_loc=None):
        self.rate_loc = rate_loc
        self.unit_select_loc = unit_select_loc


def _mkitem(index):
    return RateFormItem((By.CSS_SELECTOR, "input#rate_" + str(index)),
                        Select((By.CSS_SELECTOR, "select#per_time_" + str(index))))

rate_form = Form(
Exemple #20
0
from widgetastic.utils import ParametrizedLocator, ParametrizedString
from widgetastic.widget import Text, ParametrizedView
from widgetastic_manageiq import Select
from widgetastic_patternfly import Input, Button, Dropdown

from cfme.base.login import BaseLoggedInPage
import cfme.fixtures.pytest_selenium as sel
import cfme.web_ui.accordion as accordion
from cfme.web_ui import Form, Tree, fill, flash, form_buttons, match_location, Select as Select_old
from utils.appliance import Navigatable
from utils.appliance.implementations.ui import navigator, navigate_to, CFMENavigateStep
from utils.pretty import Pretty
from utils.update import Updateable
from utils.version import LOWEST, pick

assignment_tree = Tree("//div[@id='cb_assignments_treebox']/ul")

match_page = partial(match_location,
                     controller='chargeback',
                     title='Chargeback')


class ChargebackView(BaseLoggedInPage):
    @property
    def in_chargeback(self):
        return (self.logged_in_as_current_user
                and self.navigation.currently_selected
                == ['Cloud Intel', 'Chargeback'])

    @property
    def is_displayed(self):
Exemple #21
0
import cfme.web_ui.flash as flash
import cfme.web_ui.toolbar as tb
from cfme.web_ui.tabstrip import select_tab
from cfme.web_ui import Form, Table, Tree, UpDownSelect, fill, Select, ScriptBox, DHTMLSelect,\
    Region, form_buttons, accordion, Input, AngularSelect
import cfme.exceptions as exceptions
from utils.update import Updateable
from utils import error, version
from collections import Mapping
import re
from utils.log import logger
from utils import classproperty, pretty
from utils.wait import wait_for

tree = Tree({
    version.LOWEST: '//table//tr[@title="Datastore"]/../..',
    '5.3': '//ul//a[@title="Datastore"]/../../..'
})

datastore_tree = partial(accordion.tree, "Datastore", "Datastore")
cfg_btn = partial(tb.select, 'Configuration')


def datastore_checkbox(name):
    return version.pick({
        version.LOWEST:
        "//img[contains(@src, 'chk') and ../../td[normalize-space(.)={}]]",
        "5.5":
        "//input[@type='checkbox' and ../../td[normalize-space(.)={}]]"
    }).format(quoteattr(name))

                                  "//input[@id='tab_description']")])

box_form = Form(fields=[('box_label', "//input[@id='group_label']"
                         ), ('box_desc', "//input[@id='group_description']")])

element_form = Form(fields=[(
    'ele_label',
    "//input[@id='field_label']"), (
        'ele_name', "//input[@id='field_name']"
    ), ('ele_desc', "//input[@id='field_description']"
        ), ('choose_type', Select("//select[@id='field_typ']")
            ), ('default_text_box', "//input[@id='field_default_value']")])

service_dialog_tree = Tree(
    version.pick({
        'default': "//div[@id='dialogs_tree_div']//table",
        '5.3': "//div[@id='dialogs_tree_div']//ul"
    }))


def _all_servicedialogs_add_new(context):
    service_dialog_tree.click_path('All Dialogs')
    cfg_btn('Add a new Dialog')
    sel.wait_for_element(label_form.label)


nav.add_branch(
    'automate_customization', {
        'service_dialogs': [
            nav.partial(accordion.click, 'Service Dialogs'), {
                'service_dialog_new':
Exemple #23
0
from cfme.web_ui.menu import nav
import cfme.web_ui.flash as flash
import cfme.web_ui.toolbar as tb
from cfme.web_ui.tabstrip import select_tab
from cfme.web_ui import Form, Table, Tree, UpDownSelect, fill, Select, ScriptBox, DHTMLSelect,\
    Region, form_buttons, accordion, Input, AngularSelect
import cfme.exceptions as exceptions
from utils.update import Updateable
from utils import error, version, on_rtd
from collections import Mapping
import re
from utils.log import logger
from utils import classproperty, pretty
from utils.wait import wait_for

tree = Tree('//ul//a[@title="Datastore"]/../../..')

datastore_tree = partial(accordion.tree, "Datastore", "Datastore")
cfg_btn = partial(tb.select, 'Configuration')


def datastore_checkbox(name):
    return version.pick({
        version.LOWEST:
        "//img[contains(@src, 'chk') and ../../td[normalize-space(.)={}]]",
        "5.5":
        "//input[@type='checkbox' and ../../td[normalize-space(.)={}]]"
    }).format(quoteattr(name))


def table_select(name):
cfg_btn = partial(toolbar.select, 'Configuration')
pol_btn = partial(toolbar.select, 'Policy')
lcl_btn = partial(toolbar.select, 'Lifecycle')
mon_btn = partial(toolbar.select, 'Monitoring')
pwr_btn = partial(toolbar.select, 'Power')

create_button = form_buttons.FormButton("Create")

manage_policies_tree = CheckboxTree("//div[@id='protect_treebox']/ul")

manage_policies_page = Region(locators={
    'save_button': form_buttons.save,
})

snapshot_tree = Tree("//div[@id='snapshots_treebox']/ul")

snapshot_form = Form(
    fields=[('name', Input('name')), ('descrition', Input('description')),
            ('snapshot_memory',
             Input('snap_memory')), (
                 'create_button',
                 create_button), ('cancel_button', form_buttons.cancel)])

retirement_date_form = Form(
    fields=[('retirement_date_text', Calendar("miq_date_1")),
            ('retirement_warning_select',
             Select("//select[@id='retirement_warn']"))])

retire_remove_button = "//span[@id='remove_button']/a/img"
Exemple #25
0
from functools import partial
from utils import version
from utils.virtual_machines import deploy_template
from utils.log import logger
from utils.pretty import Pretty
from utils.update import Updateable
from utils.wait import wait_for

cfg_btn = partial(toolbar.select, 'Configuration')
pol_btn = partial(toolbar.select, 'Policy')
lcl_btn = partial(toolbar.select, 'Lifecycle')
mon_btn = partial(toolbar.select, 'Monitoring')
pwr_btn = partial(toolbar.select, 'Power')

visible_tree = Tree("//div[@class='dhxcont_global_content_area']"
                    "[not(contains(@style, 'display: none'))]/div/div/div"
                    "/ul[@class='dynatree-container']")

details_page = Region(infoblock_type='detail')

list_page = Region(title='Instances')

policy_page = Region(
    locators={
        'policy_tree': Tree('//div[@class="containerTableStyle"]/table')
    })

manage_policies_tree = CheckboxTree({
    version.LOWEST: "//div[@id='treebox']/div/table",
    "5.3": "//div[@id='protect_treebox']/ul"
})
Exemple #26
0
from cfme.web_ui.menu import nav
from utils.timeutil import parsetime
from utils.update import Updateable
from utils.wait import wait_for, TimedOutError


def make_tree_locator(acc_name, root_name):
    """ Make a specific locator for the tree in accordions.

    Args:
        acc_name: Accordion title
        root_name: Title of the root node of the tree in the accordion.
    """
    return '//span[.="%s"]/../..//table//tr[contains(@title, "%s")]/../..' % (acc_name, root_name)

settings_tree = Tree(make_tree_locator("Settings", "Region"))
access_tree = Tree(make_tree_locator("Access Control", "Region"))
diagnostics_tree = Tree(make_tree_locator("Diagnostics", "Region"))
database_tree = Tree(make_tree_locator("Database", "VMDB"))

server_roles = Form(
    fields=[
        ('ems_metrics_coordinator', "//input[@id='server_roles_ems_metrics_coordinator']"),
        ('ems_operations', "//input[@id='server_roles_ems_operations']"),
        ('ems_metrics_collector', "//input[@id='server_roles_ems_metrics_collector']"),
        ('reporting', "//input[@id='server_roles_reporting']"),
        ('ems_metrics_processor', "//input[@id='server_roles_ems_metrics_processor']"),
        ('scheduler', "//input[@id='server_roles_scheduler']"),
        ('smartproxy', "//input[@id='server_roles_smartproxy']"),
        ('database_operations', "//input[@id='server_roles_database_operations']"),
        ('smartstate', "//input[@id='server_roles_smartstate']"),
entry_table = Table("//div[@id='field_values_div']/form/fieldset/table")
text_area_table = Table(
    "//div[@id='dialog_field_div']/fieldset/table[@class='style1']")
text_area_table = Table({
    version.LOWEST:
    "//div[@id='dialog_field_div']/fieldset/table"
    "[@class='style1']",
    '5.5':
    "//div[@id='dialog_field_div']/div[@class='form-horizontal']"
})
dynamic_tree = Tree({
    version.LOWEST:
    "//div[@class='dhxcont_global_content_area']"
    "[not(contains(@style, 'display: none'))]/div/div/div/div/div"
    "/fieldset/div/ul[@class='dynatree-container']",
    '5.4':
    "//div[@class='dhxcont_global_content_area']"
    "[not(contains(@style, 'display: none'))]/div/div/div/div/div/div"
    "/div/div/div/ul[@class='dynatree-container']",
    '5.5':
    "//div[@class='modal-content']/div/div/ul[@class='dynatree-container']"
})

label_form = Form(
    fields=[('label',
             Input("label")), ('description_text', Input("description")),
            ('submit_button',
             Input("chkbx_submit")), ('cancel_button', Input("chkbx_cancel"))])

tab_form = Form(
    fields=[('tab_label',
             Input("tab_label")), ('tab_desc', Input("tab_description"))])
Exemple #28
0
from functools import partial

from selenium.webdriver.common.by import By

import cfme.web_ui.accordion as accordion
import cfme.web_ui.toolbar as tb
import cfme.fixtures.pytest_selenium as sel
from cfme.web_ui import Form, Select, Tree, fill, flash
from cfme.web_ui.menu import nav
from utils.update import Updateable

rate_tree = Tree("//div[@id='cb_rates_treebox']/ul")
tb_select = partial(tb.select, "Configuration")
tb_select_new_chargeback = nav.fn(partial(tb_select, "Add a new Chargeback Rate"))
tb_select_edit_chargeback = nav.fn(partial(tb_select, "Edit this Chargeback Rate"))


class RateFormItem(object):
    def __init__(self, rate_loc=None, unit_select_loc=None):
        self.rate_loc = rate_loc
        self.unit_select_loc = unit_select_loc


def _mkitem(index):
    return RateFormItem(
        (By.CSS_SELECTOR, "input#rate_" + str(index)), Select((By.CSS_SELECTOR, "select#per_time_" + str(index)))
    )


rate_form = Form(
    fields=[
    class Snapshot(object):
        snapshot_tree = deferred_verpick({
            version.LOWEST:
            Tree("//div[@id='snapshots_treebox']/ul"),
            '5.7.0.1':
            BootstrapTreeview('snapshot_treebox')
        })

        def __init__(self,
                     name=None,
                     description=None,
                     memory=None,
                     parent_vm=None):
            super(Vm.Snapshot, self).__init__()
            self.name = name
            self.description = description
            self.memory = memory
            self.vm = parent_vm

        def _nav_to_snapshot_mgmt(self):
            snapshot_title = '"Snapshots" for Virtual Machine "{}"'.format(
                self.vm.name)
            if summary_title() != snapshot_title:
                self.vm.load_details()
                sel.click(InfoBlock.element("Properties", "Snapshots"))

        def does_snapshot_exist(self):
            self._nav_to_snapshot_mgmt()
            try:
                if self.name is not None:
                    self.snapshot_tree.find_path_to(
                        re.compile(self.name + r".*?"))
                else:
                    self.snapshot_tree.find_path_to(
                        re.compile(self.description + r".*?"))
                return True
            except CandidateNotFound:
                return False
            except NoSuchElementException:
                return False

        def wait_for_snapshot_active(self):
            self._nav_to_snapshot_mgmt()
            try:
                self.snapshot_tree.click_path(
                    *self.snapshot_tree.find_path_to(re.compile(self.name)))
                if sel.is_displayed_text(self.name + " (Active)"):
                    return True
            except CandidateNotFound:
                return False

        def create(self):
            self._nav_to_snapshot_mgmt()
            toolbar.select('Create a new snapshot for this VM')
            if self.name is not None:
                fill(snapshot_form, {
                    'name': self.name,
                    'description': self.description,
                    'snapshot_memory': self.memory
                },
                     action=snapshot_form.create_button)
            else:
                fill(snapshot_form, {
                    'description': self.description,
                    'snapshot_memory': self.memory
                },
                     action=snapshot_form.create_button)
            wait_for(self.does_snapshot_exist,
                     num_sec=300,
                     delay=20,
                     fail_func=sel.refresh,
                     handle_exception=True)

        def delete(self, cancel=False):
            self._nav_to_snapshot_mgmt()
            toolbar.select('Delete Snapshots',
                           'Delete Selected Snapshot',
                           invokes_alert=True)
            sel.handle_alert(cancel=cancel)
            if not cancel:
                flash.assert_message_match(
                    'Remove Snapshot initiated for 1 '
                    'VM and Instance from the CFME Database')

        def delete_all(self, cancel=False):
            self._nav_to_snapshot_mgmt()
            toolbar.select('Delete Snapshots',
                           'Delete All Existing Snapshots',
                           invokes_alert=True)
            sel.handle_alert(cancel=cancel)
            if not cancel:
                flash.assert_message_match(
                    'Remove All Snapshots initiated for 1 VM and '
                    'Instance from the CFME Database')

        def revert_to(self, cancel=False):
            self._nav_to_snapshot_mgmt()
            self.snapshot_tree.click_path(
                *self.snapshot_tree.find_path_to(re.compile(self.name)))
            toolbar.select('Revert to selected snapshot', invokes_alert=True)
            sel.handle_alert(cancel=cancel)
            flash.assert_message_match(
                'Revert To Snapshot initiated for 1 VM and Instance from '
                'the CFME Database')
             ), ('continue_button',
                 submit_button), ('cancel_button', form_buttons.cancel)])

provisioning_form = tabstrip.TabStripForm(
    fields=[('submit_button', submit_button),
            ('cancel_button', form_buttons.cancel)],
    tab_fields=OrderedDict([
        ('Request', [
            ('email', '//input[@name="requester__owner_email"]'),
            ('first_name', '//input[@id="requester__owner_first_name"]'),
            ('last_name', '//input[@id="requester__owner_last_name"]'),
            ('notes', '//textarea[@id="requester__request_notes"]'),
            ('manager_name', '//input[@id="requester__owner_manager"]'),
        ]),
        ('Purpose', [
            ('apply_tags', Tree('//div[@id="all_tags_treebox"]//table')),
        ]),
        ('Catalog',
         [('vm_filter', Select('//select[@id="service__vm_filter"]')),
          ('catalog_name', Table('//div[@id="prov_vm_div"]/table')),
          ('num_vms', Select('//select[@id="service__number_of_vms"]')),
          ('vm_name', '//input[@name="service__vm_name"]'),
          ('vm_description', '//textarea[@id="service__vm_description"]'),
          ('provision_type',
           Select('//select[@id="service__provision_type"]')),
          ('linked_clone', '//input[@id="service__linked_clone"]'),
          ('pxe_server', Select('//select[@id="service__pxe_server_id"]')),
          ('pxe_image', Table('//div[@id="prov_pxe_img_div"]/table')),
          ('iso_file', Table('//div[@id="prov_iso_img_div"]/table'))]),
        ('Environment', [
            ('automatic_placement',
mon_btn = partial(toolbar.select, 'Monitoring')
pwr_btn = partial(toolbar.select, 'Power')

create_button = form_buttons.FormButton("Create")

manage_policies_tree = CheckboxTree({
    version.LOWEST: "//div[@id='treebox']/div/table",
    "5.3": "//div[@id='protect_treebox']/ul"
})

manage_policies_page = Region(locators={
    'save_button': form_buttons.save,
})

snapshot_tree = Tree({
    version.LOWEST: "//div[@id='treebox']/div/table",
    "5.3": "//div[@id='snapshots_treebox']/ul"
})

snapshot_form = Form(
    fields=[('name', Input('name')), ('descrition', Input('description')),
            ('snapshot_memory',
             Input('snap_memory')), (
                 'create_button',
                 create_button), ('cancel_button', form_buttons.cancel)])

retirement_date_form = Form(
    fields=[('retirement_date_text', Calendar("miq_date_1")),
            ('retirement_warning_select',
             Select("//select[@id='retirement_warn']"))])

retire_remove_button = "//span[@id='remove_button']/a/img"
Exemple #32
0
def reports_tree():
    if version.current_version() >= '5.7':
        return BootstrapTreeview("menu_roles_treebox")
    else:
        return Tree("//div[@id='menu_roles_treebox']/ul")
Exemple #33
0
from contextlib import contextmanager

from cfme.fixtures import pytest_selenium as sel
from cfme.intelligence.reports.ui_elements import FolderManager
from cfme.web_ui import Region, Tree, accordion, form_buttons, menu
from cfme.web_ui.multibox import MultiBoxSelect
from utils.log import logger

menu.nav.add_branch(
    "reports", {
        "report_menus_group":
        lambda ctx: accordion.tree("Edit Report Menus", "All EVM Groups", ctx[
            "group"])
    })

reports_tree = Tree("//div[@id='menu_roles_treebox']/ul")

manager = FolderManager("//div[@id='folder_lists']/table")
report_select = MultiBoxSelect(
    "//select[@id='available_reports']",
    "//select[@id='selected_reports']",
    "//a[@title='Move selected reports right']/img",
    "//a[@title='Move selected reports left']/img",
)

buttons = Region(locators=dict(
    commit="//a[@title='Commit report management changes']/img",
    discard="//a[@title='Discard report management changes']/img",
))

default_button = form_buttons.FormButton("Reset All menus to CFME defaults")
Exemple #34
0
from cfme.intelligence.reports.ui_elements import FolderManager
from cfme.web_ui import Region, Tree, accordion, form_buttons, menu
from cfme.web_ui.multibox import MultiBoxSelect
from utils import version
from utils.log import logger

menu.nav.add_branch(
    "reports",
    {
        "report_menus_group":
        lambda ctx: accordion.tree("Edit Report Menus", "All EVM Groups", ctx["group"])
    }
)

reports_tree = Tree({
    "5.3": "//div[@id='menu_roles_treebox']/ul",
    version.LOWEST: "//div[@id='treebox']//table[not(tbody/tr/td[@class='hiddenRow'])]"
})

manager = FolderManager("//div[@id='folder_lists']/table")
report_select = MultiBoxSelect(
    "//select[@id='available_reports']",
    "//select[@id='selected_reports']",
    "//a[@title='Move selected reports right']/img",
    "//a[@title='Move selected reports left']/img",
)

buttons = Region(locators=dict(
    commit="//a[@title='Commit report management changes']/img",
    discard="//a[@title='Discard report management changes']/img",
))
Exemple #35
0
import cfme.fixtures.pytest_selenium as sel
from cfme.web_ui.menu import nav
import cfme.web_ui.flash as flash
import cfme.web_ui.toolbar as tb
from cfme.web_ui.tabstrip import select_tab
from cfme.web_ui import Form, Table, Tree, fill, Select, ScriptBox, DHTMLSelect, Region
import cfme.exceptions as exceptions
from utils.update import Updateable
from utils import error, version
from collections import Mapping
import re
from utils.log import logger

tree = Tree(
    version.pick({
        'default': '//table//tr[@title="Datastore"]/../..',
        '9.9.9.9': '//ul//a[@title="Datastore"]/../../..'
    }))
cfg_btn = partial(tb.select, 'Configuration')

submit_and_cancel_buttons = [
    ('add_btn', "//ul[@id='form_buttons']/li/img[@alt='Add']"),
    ('save_btn', "//ul[@id='form_buttons']/li/img[@alt='Save Changes']"),
    ('cancel_btn', "//ul[@id='form_buttons']/li/img[@alt='Cancel']")
]


def datastore_checkbox(name):
    return "//img[contains(@src, 'chk') and ../../td[.='%s']]" % name

Exemple #36
0
credential_form = Form(
    fields=[
        ('default_button', "//div[@id='auth_tabs']/ul/li/a[@href='#default']"),
        ('default_principal', "//*[@id='default_userid']"),
        ('default_secret', "//*[@id='default_password']"),
        ('default_verify_secret', "//*[@id='default_verify']"),
        ('amqp_button', "//div[@id='auth_tabs']/ul/li/a[@href='#amqp']"),
        ('amqp_principal', "//*[@id='amqp_userid']"),
        ('amqp_secret', "//*[@id='amqp_password']"),
        ('amqp_verify_secret', "//*[@id='amqp_verify']"),
        ('validate_btn', page_specific_locators.creds_validate_btn)
    ])

manage_policies_form = Form(
    fields=[
        ('policy_select', Tree("//div[@id='treebox']/div/table")),
    ])

cfg_btn = partial(tb.select, 'Configuration')
pol_btn = partial(tb.select, 'Policy')

nav.add_branch('clouds_providers',
               {'cloud_provider_new': lambda _: cfg_btn('Add a New Cloud Provider'),
                'cloud_provider_discover': lambda _: cfg_btn('Discover Cloud Providers'),
                'cloud_provider': [lambda ctx: sel.click(Quadicon(ctx['provider'].name,
                                                                  'cloud_prov')),
                                   {'cloud_provider_edit':
                                    lambda _: cfg_btn('Edit this Cloud Provider'),
                                    'cloud_provider_policy_assignment':
                                    lambda _: pol_btn('Manage Policies')}]})
Exemple #37
0
# -*- coding: utf-8 -*-
from functools import partial
from collections import OrderedDict
from cfme.fixtures import pytest_selenium as sel
from cfme.web_ui import Form, Radio, Select, Table, accordion, fill,\
    flash, form_buttons, menu, tabstrip, DHTMLSelect, Input, Tree, AngularSelect
from cfme.web_ui import toolbar as tb
from utils.update import Updateable
from utils.pretty import Pretty
from utils.version import current_version
from utils import version

cfg_btn = partial(tb.select, "Configuration")
accordion_tree = partial(accordion.tree, "Catalog Items")
policy_btn = partial(tb.select, "Policy")
dynamic_tree = Tree(
    "//div[@id='basic_info_div']//ul[@class='dynatree-container']")

template_select_form = Form(
    fields=[('template_table', Table('//div[@id="prov_vm_div"]/table')
             ), ('add_button',
                 form_buttons.add), ('cancel_button', form_buttons.cancel)])

# Forms
basic_info_form = Form(
    fields=[('name_text',
             Input("name")), (
                 'description_text',
                 Input("description")), ('display_checkbox', Input("display")),
            ('select_catalog', Select("//select[@id='catalog_id']")
             ), ('select_dialog', Select("//select[@id='dialog_id']")),
            ('select_orch_template', Select("//select[@id='template_id']")
QUADICON_TITLE_LOCATOR = ("//div[@id='quadicon']/../../../tr/td/a[contains(@href,'vm_infra/x_show')"
                         " or contains(@href, '/show/')]")  # for provider specific vm/template page

details_page = Region(infoblock_type='detail')

cfg_btn = partial(toolbar.select, 'Configuration')
pol_btn = partial(toolbar.select, 'Policy')
lcl_btn = partial(toolbar.select, 'Lifecycle')
mon_btn = partial(toolbar.select, 'Monitoring')
pwr_btn = partial(toolbar.select, 'Power')

create_button = form_buttons.FormButton("Create")

visible_tree = Tree("//div[@class='dhxcont_global_content_area']"
                    "[not(contains(@style, 'display: none'))]/div/div/div"
                    "/ul[@class='dynatree-container']")

manage_policies_tree = CheckboxTree(
    {
        version.LOWEST: "//div[@id='treebox']/div/table",
        "5.3": "//div[@id='protect_treebox']/ul"
    }
)


manage_policies_page = Region(
    locators={
        'save_button': form_buttons.save,
    })
Exemple #39
0
import cfme.web_ui.flash as flash
import cfme.web_ui.toolbar as tb
from cfme.web_ui.tabstrip import select_tab
from cfme.web_ui import Form, Table, Tree, UpDownSelect, fill, Select, ScriptBox, DHTMLSelect,\
    Region, form_buttons, accordion, Input
import cfme.exceptions as exceptions
from utils.update import Updateable
from utils import error, version
from collections import Mapping
import re
from utils.log import logger
from utils import classproperty, pretty
from utils.wait import wait_for

tree = Tree({
    version.LOWEST: '//table//tr[@title="Datastore"]/../..',
    '5.3': '//ul//a[@title="Datastore"]/../../..'})

datastore_tree = partial(accordion.tree, "Datastore", "Datastore")
cfg_btn = partial(tb.select, 'Configuration')


def datastore_checkbox(name):
    return "//img[contains(@src, 'chk') and ../../td[normalize-space(.)='%s']]" % name


def table_select(name):
    cb = datastore_checkbox(name)
    wait_for(sel.is_displayed, [cb], num_sec=5, delay=0.2)
    sel.check(datastore_checkbox(name))
Exemple #40
0
    class Snapshot(object):
        snapshot_tree = deferred_verpick({
            version.LOWEST:
            Tree("//div[@id='snapshots_treebox']/ul"),
            '5.7.0.1':
            BootstrapTreeview('snapshot_treebox')
        })

        def __init__(self,
                     name=None,
                     description=None,
                     memory=None,
                     parent_vm=None):
            super(Vm.Snapshot, self).__init__()
            self.name = name
            self.description = description
            self.memory = memory
            self.vm = parent_vm

        def _nav_to_snapshot_mgmt(self):
            snapshot_title = '"Snapshots" for Virtual Machine "{}"'.format(
                self.vm.name)
            if summary_title() != snapshot_title:
                self.vm.load_details()
                sel.click(InfoBlock.element("Properties", "Snapshots"))

        @property
        def exists(self):
            self._nav_to_snapshot_mgmt()
            try:
                self.snapshot_tree.find_path_to(
                    re.compile(r"{}.*?".format(self.name or self.description)))
                return True
            except CandidateNotFound:
                return False
            except NoSuchElementException:
                return False

        def _click_tree_path(self, prop):
            """Find and click the given property in a snapshot tree path.

            Args:
                prop (str): Property to check (name or description).

            Returns:
                None
            """
            self.snapshot_tree.click_path(
                *self.snapshot_tree.find_path_to(re.compile(prop)))

        @property
        def active(self):
            """Check if the snapshot is active.

            Returns:
                bool: True if snapshot is active, False otherwise.
            """
            self._nav_to_snapshot_mgmt()
            try:
                self._click_tree_path(self.name or self.description)
                if sel.is_displayed_text("{} (Active)".format(
                        self.name or self.description)):
                    return True
            except CandidateNotFound:
                return False

        def create(self):
            snapshot_dict = {'description': self.description}
            self._nav_to_snapshot_mgmt()
            toolbar.select('Create a new snapshot for this VM')

            if self.name is not None:
                snapshot_dict['name'] = self.name

            if self.vm.provider.mgmt.is_vm_running(self.vm.name):
                snapshot_dict["snapshot_memory"] = self.memory

            fill(snapshot_form,
                 snapshot_dict,
                 action=snapshot_form.create_button)
            wait_for(lambda: self.exists,
                     num_sec=300,
                     delay=20,
                     fail_func=sel.refresh,
                     handle_exception=True)

        def delete(self, cancel=False):
            self._nav_to_snapshot_mgmt()
            toolbar.select('Delete Snapshots',
                           'Delete Selected Snapshot',
                           invokes_alert=True)
            sel.handle_alert(cancel=cancel)
            if not cancel:
                flash.assert_message_match(
                    'Remove Snapshot initiated for 1 '
                    'VM and Instance from the CFME Database')

        def delete_all(self, cancel=False):
            self._nav_to_snapshot_mgmt()
            toolbar.select('Delete Snapshots',
                           'Delete All Existing Snapshots',
                           invokes_alert=True)
            sel.handle_alert(cancel=cancel)
            if not cancel:
                flash.assert_message_match(
                    'Remove All Snapshots initiated for 1 VM and '
                    'Instance from the CFME Database')

        def revert_to(self, cancel=False):
            self._nav_to_snapshot_mgmt()

            self._click_tree_path(self.name or self.description)

            toolbar.select('Revert to selected snapshot', invokes_alert=True)
            sel.handle_alert(cancel=cancel)
            flash.assert_message_match(
                'Revert To Snapshot initiated for 1 VM and Instance from '
                'the CFME Database')
from collections import Mapping
from copy import copy
from functools import partial

from selenium.webdriver.common.by import By

import cfme.web_ui.accordion as accordion
import cfme.web_ui.toolbar as tb
import cfme.fixtures.pytest_selenium as sel
from cfme.web_ui import Form, Select, Tree, fill, flash, form_buttons
from cfme.web_ui.menu import nav
from utils.pretty import Pretty
from utils.update import Updateable
from utils.version import LOWEST

rate_tree = Tree("//div[@id='cb_rates_treebox']/ul")
assignment_tree = Tree("//div[@id='cb_assignments_treebox']/ul")
tb_select = partial(tb.select, "Configuration")
tb_select_new_chargeback = nav.fn(partial(tb_select, "Add a new Chargeback Rate"))
tb_select_edit_chargeback = nav.fn(partial(tb_select, "Edit this Chargeback Rate"))


class RateFormItem(Pretty):
    pretty_attrs = ['rate_loc', 'unit_select_loc']

    def __init__(self, rate_loc=None, unit_select_loc=None):
        self.rate_loc = rate_loc
        self.unit_select_loc = unit_select_loc


def _mkitem(index):
from utils.db_queries import get_server_id, get_server_name, get_server_region
from utils.timeutil import parsetime
from utils.update import Updateable
from utils.wait import wait_for, TimedOutError


def make_tree_locator(acc_name, root_name):
    """ Make a specific locator for the tree in accordions.

    Args:
        acc_name: Accordion title
        root_name: Title of the root node of the tree in the accordion.
    """
    return '//span[.="%s"]/../..//table//tr[contains(@title, "%s")]/../..' % (acc_name, root_name)

settings_tree = Tree(make_tree_locator("Settings", "Region"))
access_tree = Tree(make_tree_locator("Access Control", "Region"))
diagnostics_tree = Tree(make_tree_locator("Diagnostics", "Region"))
database_tree = Tree(make_tree_locator("Database", "VMDB"))

server_roles = Form(
    fields=[
        ('ems_metrics_coordinator', "//input[@id='server_roles_ems_metrics_coordinator']"),
        ('ems_operations', "//input[@id='server_roles_ems_operations']"),
        ('ems_metrics_collector', "//input[@id='server_roles_ems_metrics_collector']"),
        ('reporting', "//input[@id='server_roles_reporting']"),
        ('ems_metrics_processor', "//input[@id='server_roles_ems_metrics_processor']"),
        ('scheduler', "//input[@id='server_roles_scheduler']"),
        ('smartproxy', "//input[@id='server_roles_smartproxy']"),
        ('database_operations', "//input[@id='server_roles_database_operations']"),
        ('smartstate', "//input[@id='server_roles_smartstate']"),