class BaseLoggedInPage(View): """This is base view for MTA""" header = Text(locator=".//img[@id='header-logo']") home_navigation = HOMENavigation("//ul") navigation = MTANavigation('//ul[@class="list-group"]') setting = DropdownMenu( locator=".//li[contains(@class, 'dropdown') and .//span[@class='pficon pficon-user']]" ) help = DropdownMenu( locator=".//li[contains(@class, 'dropdown') and .//span[@class='pficon pficon-help']]" ) # only if no project available blank_state = View.nested(BlankStateView) @property def is_empty(self): """Check project is available or not; blank state""" return self.blank_state.is_displayed @property def is_displayed(self): return self.header.is_displayed and self.help.is_displayed
class SystemRulesView(BaseLoggedInPage): """This view represents System rules tab page""" paginator = Pagination( locator='.//div[contains(@class, "pf-c-pagination")]') show_all_rules = Text(".//input[@id='showAllRules']") table = Table( locator='.//table[contains(@aria-label, "Table")]', column_widgets={ "Provider ID": Button(locator='.//th[@data-label="Provider ID"]/button'), "Number of rules": Button(locator=".//th[@data-label='Number of rules']/button"), 4: Dropdown(), }, ) filter_type_selector = DropdownMenu( locator='.//div[contains(@class, "pf-c-select")]') filter_by = MTACheckboxSelect( locator='.//span[@class="pf-c-select__toggle-arrow"]//parent::button[' 'contains(@aria-labelledby, "Filter by Source")]/parent::div |' ' .//span[@class="pf-c-select__toggle-arrow"]//parent::button[' 'contains(@aria-labelledby, "Filter by Target")]/parent::div') clear = Text('.//button[contains(text(), "Clear all filters")]') @property def is_displayed(self): return self.table.is_displayed and self.show_all_rules.is_displayed
class ProjectView(AllProjectView): project_dropdown = DropdownMenu( locator= ".//li[contains(@class, 'dropdown') and .//span[@class='nav-item']]") @property def is_displayed(self): return self.project_dropdown.is_displayed
class ProjectView(AllProjectView): project_dropdown = DropdownMenu( locator= "//div[@class='pf-c-context-selector' or @class='pf-c-context-selector " "pf-m-expanded']") def select_project_dropdown(self, project_name): self.project_dropdown.item_select(project_name) @property def is_displayed(self): return self.project_dropdown.is_displayed
class BaseLoggedInPage(View): """This is base view for MTA""" header = Text(locator=".//img[@alt='brand']") navigation = MTANavigation(locator='//ul[@class="pf-c-nav__list"]') logout_button = Dropdown(text="mta") setting = DropdownMenu( locator= ".//li[contains(@class, 'dropdown') and .//span[@class='pficon pficon-user']]" ) help = Button(id="aboutButton") # only if no project available blank_state = View.nested(BlankStateView) def validate_url(self): """The logged in Page in both web console and operator are same so added a url check to differentiate in the view""" if self.context["object"].application.mta_context == "ViaOperatorUI": url = self.context["object"].application.ocphostname elif self.context["object"].application.mta_context == "ViaSecure": url = self.context["object"].application.ocpsecurehostname elif self.context["object"].application.mta_context == "ViaWebUI": url = self.context["object"].application.hostname return url in self.context[ "object"].application.web_ui.widgetastic_browser.url @property def is_empty(self): """Check project is available or not; blank state""" return self.blank_state.is_displayed and self.validate_url() @property def is_displayed(self): return self.header.is_displayed and self.help.is_displayed and self.validate_url( ) def logout(self): self.view.logout_button.item_select("Logout")
class AllApplicationsView(BaseLoggedInPage): """Class for All applications view""" filter_application = FilterInput(id="filter") title = Text( locator=".//div[text()[normalize-space(.)='Application List']]") send_feedback = Text(locator=".//a[contains(text(), 'Send Feedback')]") clear = Text('.//a[@id="clear-filters"]') filter_selector = DropdownMenu( locator='.//span[@class="filter-by"]/parent::button/parent::div') application_table = ApplicationList() sort_selector = DropdownMenu( locator='.//span[@id="sort-by"]/parent::button/parent::div') alpha_sort = Button(locator=".//button[@id='sort-order']") def clear_filters(self): if self.clear.is_displayed: self.clear.click() def search(self, search_value, filter_type="Name", clear_filters=False): """Fill input box with 'search_value', use 'filter_type' to choose filter selector. If no filter_type is entered then the default for page is used. """ if clear_filters: self.clear_filters() if filter_type: self.filter_selector.item_select(filter_type) self.filter_application.fill(search_value) def sort_by(self, sort_criteria): """ Select the sort criteria among Name and Story Points to sort applications list """ if self.sort_selector.items is not None: self.sort_selector.item_select(sort_criteria) @property def is_displayed(self): return self.filter_application.is_displayed and self.title.is_displayed @View.nested class tabs(View): # noqa """The tabs on the page""" @View.nested class issues(MTATab): # noqa fill_strategy = WaitFillViewStrategy("15s") TAB_NAME = "Issues" including_view = View.include(Issues, use_parent=True) @View.nested class technologies(MTATab): # noqa fill_strategy = WaitFillViewStrategy("20s") TAB_NAME = "Technologies" title = Text('.//div[contains(@class, "page-header")]/h1/div') @property def is_displayed(self): return self.title.text == "Technologies" @View.nested class hard_coded_ip(MTATab): # noqa fill_strategy = WaitFillViewStrategy("20s") TAB_NAME = "Hard-coded IP Addresses" including_view = View.include(HardCodedIP, use_parent=True)