def check_object_exist_on_combo_box_filter(self, label, objects, delimiter=","): self._select_iframe(self.uniqueIframe, self.locationTreeDiv) listObject = objects.split(delimiter) for i in listObject: self.dynamicComboboxFilter.arguments = [label, i] SeleniumAssert.element_should_be_visible(self.dynamicComboboxFilter) driver.unselect_frame()
def _check_event_details(self, eventDetails, eventDescription, eventDateTime=None, position=1, delimiter="/"): textDetailsList = eventDetails.split(delimiter) detailsXpath = self.detailsBridgeXpath.locator() eventPos = self._build_event_xpath(eventDescription, eventDateTime, position) self.secondIframe.wait_until_page_contains_element() self._select_iframe(self.secondIframe, self.eventLogTbl) self.selectItemCbb.wait_until_element_is_visible() self.selectItemCbb.select_from_list_by_label(1000) self._expand_events() for text in textDetailsList: subDetails = detailsXpath self.dynamicTextXpath.arguments = [text] strTextXpath = self.dynamicTextXpath.locator() detailsXpath = subDetails + strTextXpath fullDetailsXpath = eventPos.locator() + detailsXpath SeleniumAssert.element_should_be_visible(Element(fullDetailsXpath)) driver.unselect_frame()
def check_task_list_information_on_patching_window(self, position, name, taskType, treeFrom, connectionType, treeTo): self.dynamicTaskListTable.arguments = [position] self.dynamicTaskName.arguments = [ self.dynamicTaskListTable.locator(), name ] self.dynamicTaskType.arguments = [ self.dynamicTaskListTable.locator(), taskType ] self.dynamicTaskTreeFrom.arguments = [ self.dynamicTaskListTable.locator(), treeFrom ] self.dynamicTaskConnectType.arguments = [ self.dynamicTaskListTable.locator(), connectionType ] self.dynamicTaskTreeTo.arguments = [ self.dynamicTaskListTable.locator(), treeTo ] driver.select_frame(self.patchingIframe) self.dynamicTaskTreeTo.mouse_over() SeleniumAssert.element_should_be_visible(self.dynamicTaskName) SeleniumAssert.element_should_be_visible(self.dynamicTaskType) SeleniumAssert.element_should_be_visible(self.dynamicTaskTreeFrom) SeleniumAssert.element_should_be_visible(self.dynamicTaskConnectType) SeleniumAssert.element_should_be_visible(self.dynamicTaskTreeTo) driver.unselect_frame()
def _check_table_row_map_with_header_checkbox_selected( self, headers, values, delimiter=","): row = self._work_on_table_row_map_with_header(headers, values, False, None, delimiter) dynamicChkBxRowXpath = self.locator() + "//tr[" + str(row) + "]//input" eleChk = Element(dynamicChkBxRowXpath) SeleniumAssert.checkbox_should_be_selected(eleChk)
def _check_connect_button_state(self, frame, isEnabled): driver.select_frame(frame) self.dynamicConnectionBtn.arguments = ["Connect"] if isEnabled: SeleniumAssert.element_attribute_value_should_not_contain( self.dynamicConnectionBtn, "src", "Disabled") else: SeleniumAssert.element_attribute_value_should_contain( self.dynamicConnectionBtn, "src", "Disabled") driver.unselect_frame()
def check_work_order_priority_color(self, woName, color): self._select_iframe(workOrders.woQueueIframe, self.markCompleteBtn) returnRow = self.get_table_row_map_with_header_on_wo_queue_table( "Work Order", woName) dynamicCellXpath = self.woQueueTbl.locator() + "//tr[" + str( returnRow ) + "]/td[@aria-describedby='WorkOrderQueueGrid_Priority']/div" eleCell = Element(dynamicCellXpath) SeleniumAssert.element_attribute_value_should_contain( eleCell, "style", color) driver.unselect_frame()
def check_port_status_on_cabling_window(self, treePanel=None, treeNode=None, expectedStatus=None): driver.select_frame(connection.cablingFrame) self._wait_for_processing() if treePanel is not None and treeNode is not None: if treePanel == "From": self._click_tree_node(connection.cabTreeFromDiv, treeNode) SeleniumAssert.element_attribute_value_should_contain(connection.cableFromPathDiv, "textContent", expectedStatus) elif treePanel == "To": self._click_tree_node(connection.cabTreeToDiv, treeNode) SeleniumAssert.element_attribute_value_should_contain(connection.cableToPathDiv, "textContent", expectedStatus) driver.unselect_frame()
def check_object_state_on_multiple_select_filter(self, label, objects, containPosition="Available", delimiter=",", state="exist"): """state: exist, non-exist""" self._select_iframe(self.uniqueIframe, self.locationTreeDiv) self.dynamicLabelSelectFilter.arguments = [label] listObject = objects.split(delimiter) for i in listObject: self.dynamicObjectMultiSelect.arguments = [self.dynamicLabelSelectFilter.locator(), containPosition, i] if state == "exist": SeleniumAssert.element_should_be_visible(self.dynamicObjectMultiSelect) else: SeleniumAssert.element_should_not_be_visible(self.dynamicObjectMultiSelect) driver.unselect_frame()
def check_port_status_on_patching_window(self, statusPanel, treeNode, status): if statusPanel == "From": self.click_tree_node_patching("From", treeNode) self.dynamicPortStatus.arguments = [ self.statusFromDiv.locator(), status ] else: self.click_tree_node_patching("To", treeNode) self.dynamicPortStatus.arguments = [ self.statusToDiv.locator(), status ] driver.select_frame(self.patchingIframe) SeleniumAssert.element_should_be_visible(self.dynamicPortStatus) driver.unselect_frame()
def _check_event_exist_state_in_add_event_log_filter( self, events, stateExist, delimiter=","): """"stateExist: True, False""" listEvents = events.split(delimiter) driver.select_frame(self.uniqueIframe) for event in listEvents: self.dynamicEventsItem.arguments = [event] if stateExist: SeleniumAssert.page_should_contain_element( self.dynamicEventsItem, self.dynamicEventsItem.locator() + " does not exist") else: SeleniumAssert.page_should_not_contain_element( self.dynamicEventsItem, self.dynamicEventsItem.locator() + " exists") driver.unselect_frame()
def check_email_exist(self, emailSubject, details=None, timeout=constants.SELENPY_EMAIL_RECEIVED_TIMEOUT, delimiter=","): self.wait_until_email_received(emailSubject, timeout) if details is not None: detailsXpath = "" emailDetailslist = details.split(delimiter) for textDetails in emailDetailslist: self.dynamicEmailDetails.arguments = [textDetails] detailsXpath += self.dynamicEmailDetails.locator() fullEmailDetailsXpath = self.emailDetailsDiv.locator( ) + detailsXpath SeleniumAssert.element_should_be_visible( Element(fullEmailDetailsXpath))
def _check_device_information_on_trace(self, objectXpath, deviceInformation, delimiter="->"): """'object_xpath' is xpath string of the object we want to check(ex: //div[@id='TraceMapDialog']//div[contains(@class,'MPOPairContent MpoPair') and contains(@style,'display: block')]//div[@class = 'TraceForFiberWrapper' and contains(@style,'display: block')]//div[@id='3' and contains(@class,'ObjectDetail')]) ... 'device_information' is a list including all information of device (separate by ->)""" listInformation = deviceInformation.split(delimiter) temp = 1 for information in listInformation: dynamicInformationXpath = self.element("dynamicInformationXpath") dynamicInformationXpath.arguments = [ objectXpath, temp, information, information ] SeleniumAssert.element_should_be_visible(dynamicInformationXpath) temp += 1
def _check_icon_object_on_connections_window(self, frame, treePanel, fromDivTree, toDivTree, treeNode, icon, delimiter="/"): self._does_frame_tree_node_exist(frame, treePanel, fromDivTree, toDivTree, treeNode, delimiter) nodeXpath = self._build_page_tree_node_xpath(treePanel, fromDivTree, toDivTree, treeNode, delimiter) driver.select_frame(frame) self.treeObjectIcon.arguments = [nodeXpath, icon] SeleniumAssert.element_should_be_visible(self.treeObjectIcon) driver.unselect_frame()
def _check_mpo_connection_type_icon_not_exist(self, frame, mpoConnectionType, mpoConnectionTab=None): ''''mpoConnectionType': Options: Mpo12_Mpo12, Mpo12_4xLC, Mpo12_6xLC, Mpo24_Mpo24, Mpo24_12xLC, Mpo24_3xMpo12, Mpo24_2xMpo12, Mpo12_6xLC_EB''' driver.select_frame(frame) self._select_mpo_connection_tab(mpoConnectionTab) self.dynamicConnectionType.arguments = [ mpoConnectionType, mpoConnectionType ] self.dynamicDisabledConnectionType.arguments = [ mpoConnectionType, mpoConnectionType ] SeleniumAssert.element_should_not_be_visible( self.dynamicConnectionType) SeleniumAssert.element_should_not_be_visible( self.dynamicDisabledConnectionType) driver.unselect_frame()
def check_event_report_exist (self, eventInformation, eventDetails, delimiter=","): self._select_iframe(self.uniqueIframe, self.reportContentTbl) self._wait_for_processing(3) textInformationList = eventInformation.split(delimiter) textDetailsList = eventDetails.split(delimiter) eventRowDiv = self.headEventReportRow.locator() infoXpath = "" detailsXpath = "" for textInfo in textInformationList: self.dynamicEventReportInfo.arguments = [textInfo] infoXpath += self.dynamicEventReportInfo.locator() fullInfoXpath = eventRowDiv + infoXpath for textDetails in textDetailsList: self.dynamicEventReportDetails.arguments = [textDetails] detailsXpath += self.dynamicEventReportDetails.locator() fullEventReportXpath = fullInfoXpath + detailsXpath SeleniumAssert.element_should_be_visible(Element(fullEventReportXpath)) driver.unselect_frame()
def _check_mpo_connection_type_information(self, frame, mpoConnectionTab=None, mpoConnectionType=None, mpoBranches=None, title=None): self.dynamicConnectionType.arguments = [ mpoConnectionType, mpoConnectionType ] self.dynamicSelectedConnectionType.arguments = [mpoConnectionType] self.dynamicViewTab.arguments = [mpoConnectionTab + " Connection Type"] self._select_iframe(frame, self.dynamicViewTab) self._wait_for_processing() self._select_mpo_connection_tab(mpoConnectionTab) self._select_mpo_connection_type(mpoConnectionType) if (mpoConnectionTab is not None) and (mpoConnectionType is not None): SeleniumAssert.element_should_be_visible( self.dynamicConnectionType) SeleniumAssert.element_should_be_visible( self.dynamicSelectedConnectionType) if mpoBranches is not None: listMpoBranch = mpoBranches.split(",") for branch in listMpoBranch: self.dynamicMpoBranch.arguments = [branch] SeleniumAssert.element_should_be_visible(self.dynamicMpoBranch) if title is not None: self._check_title_attribute(self.dynamicConnectionType, title) driver.unselect_frame()
def _check_icon_mpo_port_type_on_connections_window( self, frame, treePanel, fromDivTree, toDivTree, treeNode, portType, isExisted, delimiter="/"): self._does_frame_tree_node_exist(frame, treePanel, fromDivTree, toDivTree, treeNode, delimiter) nodeXpath = self._build_page_tree_node_xpath(treePanel, fromDivTree, toDivTree, treeNode, delimiter) driver.select_frame(frame) self.treePortTypeIcon.arguments = [nodeXpath, portType] if isExisted: SeleniumAssert.element_should_be_visible(self.treePortTypeIcon) else: SeleniumAssert.element_should_not_be_visible(self.treePortTypeIcon) driver.unselect_frame()
def _check_total_trace(self, divTraceXpath, totalTrace): """Use for check number of trace ... - 'div_trace_xpath' define the page this keyword working( ex: on patching window, 'div_trace_xpath' is //div[@id='CurrentTraceResult']) ... - 'total_trace' is number of trace ... - 'close_trace_window': choosing yes or no""" traceMapXpath = self._define_trace_map_xpath(divTraceXpath) self._wait_first_object_on_trace(traceMapXpath) idLastObject = int(totalTrace) * 2 - 1 idNotExistObject = int(totalTrace) * 2 + 1 dynamicLastTraceObjectXpath = self.element("dynamicTraceObjectXpath") dynamicLastTraceObjectXpath.arguments = [ traceMapXpath, str(idLastObject) ] dynamicNotExistTraceObjectXpath = self.element( "dynamicTraceObjectXpath") dynamicNotExistTraceObjectXpath.arguments = [ traceMapXpath, str(idNotExistObject) ] SeleniumAssert.element_should_be_visible(dynamicLastTraceObjectXpath) SeleniumAssert.element_should_not_be_visible( dynamicNotExistTraceObjectXpath)
def check_wo_information_on_wo_queue(self, columns, values, priority=None, scheduling=None, dateCreated=None, expectedDate=None, additionalInformation=None, inactivityAlert=None): self._select_iframe(workOrders.woQueueIframe, self.markCompleteBtn) returnRow = self.get_table_row_map_with_header_on_wo_queue_table( columns, values) Assert.should_be_true(returnRow > 0) ######### Expand WO ############# self.woQueueTbl._click_table_cell(returnRow, 1, "double") self._select_iframe(self.woQueueGridIframe, workOrders.priorityCbb) if priority is not None: priorityCbbValue = workOrders.priorityCbb.get_selected_list_label() Assert.should_be_equal(priorityCbbValue, priority) if scheduling is not None: schedulingCbbValue = workOrders.schedulingCbb.get_selected_list_label( ) Assert.should_be_equal(schedulingCbbValue, scheduling) if dateCreated is not None: SeleniumAssert.element_attribute_value_should_be( workOrders.dateCreatedTxt, "value", dateCreated) if expectedDate is not None: SeleniumAssert.element_attribute_value_should_be( workOrders.expectedDateTxt, "value", expectedDate) if inactivityAlert is not None: SeleniumAssert.element_attribute_value_should_be( workOrders.inactivityAlertTxt, "value", inactivityAlert) if additionalInformation is not None: SeleniumAssert.element_text_should_be( workOrders.additionalInformationTxt, additionalInformation) driver.unselect_frame()
def _check_checkbox_state(self, element, state): """state: True = Selected, False = Unselected""" if state: SeleniumAssert.checkbox_should_be_selected(element) else: SeleniumAssert.checkbox_should_not_be_selected(element)
def _check_element_state(self, element, state): """state: True = Enabled, False = Disabled""" if state: SeleniumAssert.element_should_be_enabled(element) else: SeleniumAssert.element_should_be_disabled(element)
def _check_src_attribute(self, element, expected): SeleniumAssert.element_attribute_value_should_contain( element, "src", expected)
def _check_title_attribute(self, element, expected): SeleniumAssert.element_attribute_value_should_be( element, "title", expected)
def check_geomap_options_link_displays(self): SeleniumAssert.element_should_be_visible(self.optionsLnk)
def _check_trace_object(self, divTraceXpath, indexObject, mpoType=None, objectPosition=None, objectPath=None, objectType=None, portIcon=None, connectionType=None, scheduleIcon=None, informationDevice=None): """This keyword is used for check all information of a object on trace window: position, object path, object detail, object type, object connection type, scheduled icon. ... We have 9 arguments: ... - 'divTraceXpath' define the page this keyword working( ex: on patching window, 'divTraceXpath' is //div[@id='divTrace']) ... - 'indexObject': Provide the index of object we want to check ... - 'objectPosition': enter position(ex: 1, MPO12-1) ... - 'objectPath': enter object path(ex: Site/Building 01/Floor 01/Room 01/1:1 Rack 001/Panel 01/01) ... - 'objectType': enter type of object - it's defined by a png file(ex: Generic Copper Panel) ... - 'scheduleIcon': this argument is used on checking trace the object related to an uncompleted work order ... - 'connectionType': enter the connection type between this object and next object ... - 'informationDevice': enter information device(ex:01,Panel 01,1:1 Rack 001,Room 01,Floor 01,Building 01,Site)""" ##################################Define trace map################################## traceMapXpath = self._define_trace_map_xpath(divTraceXpath) self._wait_first_object_on_trace(traceMapXpath) ##################################Variables################################## idObject = int(indexObject) * 2 - 1 self.dynamicObjectXpath.arguments = [traceMapXpath, str(idObject)] ##################################Click or move object################################## if objectPath is not None: if (traceMapXpath.__contains__("//div[@id='divTrace']")): self.dynamicObjectXpath.mouse_over() else: self.dynamicObjectXpath.click_visible_element() ##################################Check Object Position################################## #--------------------------For since--------------------------# if objectPosition is not None: dynamicObjectPositionXpath = self.element( "dynamicObjectPositionXpath") dynamicObjectPositionXpath.arguments = [ traceMapXpath, str(idObject), objectPosition ] lengthSince = len(objectPosition) if (lengthSince == 5 and objectPosition[0:5] == "since"): currentTime = utils.get_current_date_time( resultFormat="%Y-%m-%d") dynamicSinceNoSpace = self.element("dynamicSinceNoSpace") dynamicSinceNoSpace.arguments = [ traceMapXpath, str(idObject), currentTime ] doesSinceNoSpaceExist = dynamicSinceNoSpace.is_element_existed( ) if (doesSinceNoSpaceExist == False): dynamicSinceWithSpace = self.element( "dynamicSinceWithSpace") dynamicSinceWithSpace.arguments = [ traceMapXpath, str(idObject), currentTime ] SeleniumAssert.element_should_be_visible( dynamicSinceWithSpace) else: SeleniumAssert.element_should_be_visible( dynamicObjectPositionXpath) ##################################Check MPO Type################################## if mpoType is not None: dynamicMpoTypeXpath = self.element("dynamicMpoTypeXpath") dynamicMpoTypeXpath.arguments = [ traceMapXpath, str(idObject), mpoType ] SeleniumAssert.element_should_be_visible(dynamicMpoTypeXpath) ##################################Check Object Path Banner################################## if objectPath is not None: dynamicObjectPathXpath = self.element("dynamicObjectPathXpath") dynamicObjectPathXpath.arguments = [traceMapXpath, objectPath] SeleniumAssert.element_should_be_visible(dynamicObjectPathXpath) ##################################Check Object Type################################## if objectType is not None: dynamicObjectTypeXpath = self.element("dynamicObjectTypeXpath") dynamicObjectTypeXpath.arguments = [ traceMapXpath, str(idObject), objectType ] SeleniumAssert.element_should_be_visible(dynamicObjectTypeXpath) ##################################Check Connection Type################################## if connectionType is not None: dynamicConnectionTypeXpath = self.element( "dynamicConnectionTypeXpath") dynamicConnectionTypeXpath.arguments = [ traceMapXpath, str(indexObject), connectionType ] SeleniumAssert.element_should_be_visible( dynamicConnectionTypeXpath) ##################################Check Port Icon################################## if portIcon is not None: dynamicPortIconXpath = self.element("dynamicPortIconXpath") dynamicPortIconXpath.arguments = [ traceMapXpath, str(idObject), portIcon ] SeleniumAssert.element_should_be_visible(dynamicPortIconXpath) ##################################Check Schedule Icon################################## if scheduleIcon is not None: self.dynamicScheduleIconXpath.arguments = [ traceMapXpath, str(idObject), scheduleIcon ] SeleniumAssert.element_should_be_visible( self.dynamicScheduleIconXpath) ##################################Check Information Device################################## if informationDevice is not None: self._check_device_information_on_trace( self.dynamicObjectXpath.locator(), informationDevice)
def check_current_window_title(self, title): SeleniumAssert.title_should_be(title, "Current window title is not " + title)
def check_wo_not_exit_on_wo_queue_window(self, woName): self.dynamicObjectOnWoQueueTbl.arguments = [woName] SeleniumAssert.element_should_not_be_visible( self.dynamicObjectOnWoQueueTbl)
def check_custom_geomap_satellite_view_state(self, enabled=True): self.dynamicUseCustomGeomapServerChk.arguments = ["Satellite"] self._select_iframe(self.uniqueIframe, self.dynamicUseCustomGeomapServerChk) SeleniumAssert.element_should_be_enabled( self.dynamicUseCustomGeomapServerChk) if enabled: SeleniumAssert.element_should_be_enabled( self.serverSatelliteViewUrlTemplateTxt) SeleniumAssert.element_should_be_enabled( self.serverSatelliteViewMaxZoomLevelTxt) SeleniumAssert.element_should_be_enabled( self.serverSatelliteViewAttributionLinkUrllink1Txt) SeleniumAssert.element_should_be_enabled( self.serverMapViewAttributionLinkUrllink1Txt) SeleniumAssert.element_should_be_enabled( self.serverSatelliteViewAttributionLinkText2Txt) SeleniumAssert.element_should_be_enabled( self.serverSatelliteViewAttributionLinkUrllink2Txt) SeleniumAssert.element_should_be_enabled( self.serverSatelliteViewAttributionLinkText3Txt) SeleniumAssert.element_should_be_enabled( self.serverSatelliteViewAttributionLinkUrllink3Txt) else: SeleniumAssert.element_should_be_disabled( self.serverSatelliteViewUrlTemplateTxt) SeleniumAssert.element_should_be_disabled( self.serverSatelliteViewMaxZoomLevelTxt) SeleniumAssert.element_should_be_disabled( self.serverSatelliteViewAttributionLinkUrllink1Txt) SeleniumAssert.element_should_be_disabled( self.serverMapViewAttributionLinkUrllink1Txt) SeleniumAssert.element_should_be_disabled( self.serverSatelliteViewAttributionLinkText2Txt) SeleniumAssert.element_should_be_disabled( self.serverSatelliteViewAttributionLinkUrllink2Txt) SeleniumAssert.element_should_be_disabled( self.serverSatelliteViewAttributionLinkText3Txt) SeleniumAssert.element_should_be_disabled( self.serverSatelliteViewAttributionLinkUrllink3Txt) driver.unselect_frame()