def mitral_define_annulus(): mitralWindow = ":mMprFrame.mAxialMprFrame_TriPlaneMprFrame" annulusTab = ":cmr42MainWindow.mPageButtons[ePage::Annulus]_QToolButton" annulusStartButton = ":groupBox.mStartAssistedButton_QPushButton" topFrame = ":mMprFrame.mSagittalMprFrame_TriPlaneMprFrame" bottomFrame = ":mMprFrame.mCoronalMprFrame_TriPlaneMprFrame" # Click on start annulus squish.mouseClick(squish.waitForObject(mitralWindow), 180, 460, 0, squish.Qt.LeftButton) # Switch to annulus tab and start annulus squish.clickButton(squish.waitForObject(annulusTab)) squish.clickButton(squish.waitForObject(annulusStartButton)) # Hardcoded annulus drawing squish.mouseClick(squish.waitForObject(topFrame), 146, 162, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(topFrame), 148, 253, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(bottomFrame), 158, 181, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(bottomFrame), 154, 252, 0, squish.Qt.LeftButton) return
def addServer(self, context): clientDetails = getClientDetails(context) squish.mouseClick(squish.waitForObject(self.SERVER_ADDRESS_BOX)) squish.type( squish.waitForObject(self.SERVER_ADDRESS_BOX), clientDetails['server'] ) squish.clickButton(squish.waitForObject(self.NEXT_BUTTON))
def select_systemic(): systemicFlowButton = ":mFlowSeriesPanelButtons.ToolButton-mFlow0PanelAction_QToolButton" squish.mouseClick(squish.waitForObject(systemicFlowButton)) return
def export_study(study_name): # status bar status = squish.waitForObject(cvi42Objects.statusBar) # Searches for study, and exports squish.waitForObject(cvi42Objects.patientlistEditBox).setText(study_name) squish.openContextMenu( squish.waitForObjectItem(cvi42Objects.studyTreeitem, study_name), 50, 5, 0) squish.activateItem( squish.waitForObjectItem(cvi42Objects.contextMenu, "Export Study")) # export dialog flow squish.mouseClick( squish.waitForObjectItem(":splitter.sidebar_QSidebar", "My Computer"), 53, 13, 0, squish.Qt.LeftButton) squish.mouseClick( squish.waitForObjectItem(":stackedWidget.treeView_QTreeView", "DATA (D:)"), 33, 14, 0, squish.Qt.LeftButton) squish.doubleClick( squish.waitForObjectItem(":stackedWidget.treeView_QTreeView", "DATA (D:)"), 34, 11, 0, squish.Qt.LeftButton) squish.clickButton(squish.waitForObject(":dcmBrowser.Choose_QPushButton")) start = time.time() while True: if status.currentMessage() == "Export Images done": break else: pass end = time.time() test.log("Time to export study: %.2f" % (end - start))
def select_pulmonary(): pulmonaryFlowButton = ":mFlowSeriesPanelButtons.ToolButton-mFlow1PanelAction_QToolButton" squish.mouseClick(squish.waitForObject(pulmonaryFlowButton)) return
def select_comparison(): comparisonFlowButton = ":mFlowSeriesPanelButtons.ToolButton-mFlow2PanelAction_QToolButton" squish.mouseClick(squish.waitForObject(comparisonFlowButton)) return
def createPublicLink(self, context, resource, password='', permissions=''): radioObjectName = '' if permissions: radioObjectName = self.getRadioObjectForPermssion(permissions) test.compare( str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text), resource.replace(context.userData['clientSyncPathUser1'], ''), ) if radioObjectName: test.compare(str(squish.waitForObjectExists(radioObjectName).text), permissions) squish.clickButton(squish.waitForObject(radioObjectName)) if password: squish.clickButton(squish.waitForObject(self.PASSWORD_CHECKBOX)) squish.mouseClick( squish.waitForObject(self.PASSWORD_CHECKBOX), 0, 0, squish.Qt.NoModifier, squish.Qt.LeftButton, ) squish.type( squish.waitForObject(self.PASSWORD_CHECKBOX), password, ) squish.clickButton(squish.waitForObject(self.CREATE_SHARE_BUTTON)) squish.waitFor(lambda: (squish.waitForObject( names.linkShares_0_0_QModelIndex).displayText == "Public link"))
def openPublicLinkDialog(self): squish.mouseClick( squish.waitForObject(self.PUBLIC_LINKS_TAB), 0, 0, squish.Qt.NoModifier, squish.Qt.LeftButton, )
def scaleModel(self, size): squish.mouseClick(self.findObjectWithText(names.mwi_btn_toolbar, "Scale")) if not waitForObject(names.mwi_chk_uniform_scaling).checked: squish.mouseClick(names.mwi_chk_uniform_scaling) self.setTextFieldValue(names.mwi_scale_model_x, size) self.click(names.mwi)
def sortBy(self, headerText): squish.mouseClick( squish.waitForObject( { "container": names.deselect_remote_folders_you_do_not_wish_to_synchronize_QHeaderView, "text": headerText, "type": "HeaderViewItem", "visible": True, } ) )
def saveToFile(self, file_name): self.click(names.mwi_btn_save_to_file, 40000) self.setTextFieldValue(names.fdg_input_name, self.testdata_dir + '\\' + file_name) self.click(names.fdg_cbo_file_type) squish.mouseClick(waitForObjectItem(names.fdg_cbo_file_type, "G-code File (*\\.gcode)")) self.click(names.fdg_btn_save) if object.exists(names.mbo_confirm_dialog): self.click(names.mbo_btn_confirm) return findFile("testdata", file_name)
def aortic_annulus(): annulusTab = ":cmr42MainWindow.mPageButtons[ePage::Annulus]_QToolButton" perimeterPoints = ":cmr42MainWindow.ToolButton-contourAction-perimeterPoints_QToolButton" aorticWindow = ":mMprFrame.mAxialMprFrame_TriPlaneMprFrame" # Click on annulus tab squish.clickButton(squish.waitForObject(annulusTab)) # Click on the perimeter contour button squish.clickButton(squish.waitForObject(perimeterPoints)) # Hardcoded mouse clicks for drawing annulus measurement squish.mouseClick(squish.waitForObject(aorticWindow), 172, 153, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 101, 208, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 172, 277, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 239, 227, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.doubleClick(squish.waitForObject(aorticWindow), 175, 152, 0, squish.Qt.LeftButton) return
def selectSyncFolder(self, context): clientDetails = getClientDetails(context) try: squish.clickButton(squish.waitForObject(self.ERROR_OK_BUTTON)) except LookupError: pass squish.clickButton(squish.waitForObject(self.SELECT_LOCAL_FOLDER)) squish.mouseClick(squish.waitForObject(self.DIRECTORY_NAME_BOX)) squish.type( squish.waitForObject(self.DIRECTORY_NAME_BOX), clientDetails['localfolder'] ) squish.clickButton(squish.waitForObject(self.CHOOSE_BUTTON)) test.compare( str(squish.waitForObjectExists(self.SELECT_LOCAL_FOLDER).text), self.sanitizeFolderPath(clientDetails['localfolder']), )
def check_report42(): reportTab = ":tabBar.Report_TabItem" greenStatusbar = ":webEngView.Save in progress_HTML_Object" reportLoading = "{container=':mCentralStack.stackWidget_QStackedWidget' name='webEndView' " "type='QWebEngineView' visible='1'}id='loader' tagName='DIV' type='HTML_Object' visible='true'}" feedbackMessage = ":webEngView.study-update-feeback_HTML_Object" counter = 0 start = time.time() # Select the Report module to check progress, wait one second to allow the system to catch up studyFunctions.click_module("Report") # squish.snooze(1) # Wait for the green progress bar to disappear while True: if object.exists(feedbackMessage): if object.exists(greenStatusbar) is True: pass else: if object.exists(greenStatusbar) is True or object.exists( reportLoading) is True: pass counter = 0 # If dialog doesn't exist for three consecutive iterations, break and time. else: counter += 1 if counter > 2: break else: pass counter += 1 if counter > 100: test.log("Can't check report42") squish.mouseClick(squish.waitForObject(reportTab)) return end = time.time() test.log("Added to report42 %.2f" % (end - start)) # squish.snooze(1) return
def selectFoldersToSync(self, context): self.openSyncDialog() # first deselect all squish.mouseClick( squish.waitForObject(self.SYNC_DIALOG_ROOT_FOLDER), 11, 11, squish.Qt.NoModifier, squish.Qt.LeftButton, ) for row in context.table[1:]: squish.mouseClick( squish.waitForObjectItem(self.SYNC_DIALOG_FOLDER_TREE, "/." + row[0]), 11, 11, squish.Qt.NoModifier, squish.Qt.LeftButton, ) squish.clickButton(squish.waitForObject(self.SYNC_DIALOG_OK_BUTTON))
def curvedMeasContour(window_name, num=3): curvedMeasurementContour = ":mContourTools.ToolButton-contourAction-openSplinePerimeterPoints_QToolButton" # Grabs Qt equivalent of given window name window, x, y = studyFunctions.find_window(window_name) # Finds and clicks on the Contour measurement button squish.clickButton(squish.waitForObject(curvedMeasurementContour)) counter = 0 while counter < num - 1: # Mouse click inside the frame of the selected window squish.mouseClick(squish.waitForObject(window), randint(0 + 50, x - 70), randint(0 + 50, y - 70), 0, squish.Qt.LeftButton) counter += 1 squish.doubleClick(squish.waitForObject(window), randint(0 + 50, x - 70), randint(0 + 50, y - 70), 0, squish.Qt.LeftButton) return
def setExpirationDate(self, context, publicLinkName, resource): test.compare( str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text), resource, ) test.compare( str(squish.waitForObjectExists(self.PUBLIC_LINK_NAME).text), publicLinkName, ) expDate = [] for row in context.table: if row[0] == 'expireDate': expDate = datetime.datetime.strptime(row[1], '%Y-%m-%d') expYear = expDate.year - 2000 squish.mouseClick( squish.waitForObject(self.EXPIRATION_DATE_FIELD), 0, 0, squish.Qt.NoModifier, squish.Qt.LeftButton, ) squish.nativeType("<Delete>") squish.nativeType("<Delete>") squish.nativeType(expDate.month) squish.nativeType(expDate.day) squish.nativeType(expYear) squish.nativeType("<Return>") squish.testSettings.silentVerifications = True squish.waitFor(lambda: (test.xvp( "publicLinkExpirationProgressIndicatorInvisible"))) waitFor(lambda: (test.vp("publicLinkExpirationProgressIndicatorInvisible"))) squish.testSettings.silentVerifications = False test.compare( str( squish.waitForObjectExists( self.EXPIRATION_DATE_FIELD).displayText), str(expDate.month) + "/" + str(expDate.day) + "/" + str(expYear), )
def selectCollaborator(self, receiver, isGroup=False): postFixInSuggestion = "" if isGroup: postFixInSuggestion = " (group)" squish.mouseClick( squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD), 0, 0, squish.Qt.NoModifier, squish.Qt.LeftButton, ) squish.type( squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD), receiver, ) squish.mouseClick( squish.waitForObjectItem(self.SUGGESTED_COLLABORATOR, receiver + postFixInSuggestion), 0, 0, squish.Qt.NoModifier, squish.Qt.LeftButton, )
def aortic_tricuspid(): tricuspidButton = ":mWorkflowGroupbox.mTricuspidPushButton_QPushButton" aorticWindow = ":mMprFrame.mAxialMprFrame_TriPlaneMprFrame" # Click on the tricuspid option squish.clickButton(squish.waitForObject(tricuspidButton)) # Hardcoded mouse clicks of tricuspid locations squish.mouseClick(squish.waitForObject(aorticWindow), 169, 195, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 197, 249, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 134, 243, 0, squish.Qt.LeftButton) # squish.snooze(1.5) return
def select_comparison(): comparisonFlowButton = ":flowTabBar.Comparison_TabItem" squish.mouseClick(squish.waitForObject(comparisonFlowButton)) return
def select_pulmonary(): pulmonaryFlowButton = ":flowTabBar.Pulmonary Flow_TabItem" squish.mouseClick(squish.waitForObject(pulmonaryFlowButton)) return
def select_systemic(): systemicFlowButton = ":flowTabBar.Systemic Flow_TabItem" squish.mouseClick(squish.waitForObject(systemicFlowButton)) return
def login(user, server): # If cvi42 already running dialog popup if object.exists(cvi42Objects.cviAlreadyRunning): squish.mouseClick(squish.waitForObject(cvi42Objects.cviAlreadyRunningOk)) # If cvi42 disconnected if object.exists(cvi42Objects.mainDialog): if object.exists(cvi42Objects.LoginDialog) is False: test.log("Already Logged In") return # Grabs desired server name squish.mouseClick(squish.waitForObject(cvi42Objects.serverBox), 164, 7, 0, squish.Qt.LeftButton) squish.mouseClick(squish.waitForObjectItem(cvi42Objects.serverBox, server), 105, 8, 0, squish.Qt.LeftButton) # Populates username and password boxes and clicks login squish.mouseClick(squish.waitForObject(cvi42Objects.usernameBox)) squish.waitForObject(cvi42Objects.usernameBox).setText(user) squish.waitForObject(cvi42Objects.passwordBox).setText(user) squish.clickButton(squish.waitForObject(cvi42Objects.LoginButton)) start = time.time() start2 = time.time() # If user already logged on dialog if object.exists(cvi42Objects.userAlreadyLoggedOn): squish.mouseClick(squish.waitForObject(cvi42Objects.userAlreadyLoggedOnOk)) # Benchmark splash screen measurements splash = squish.waitForObject(cvi42Objects.splash) message = splash.message() counter = 0 while True: try: if object.exists(cvi42Objects.splash): if message == splash.message(): pass else: splash_end = time.time() test.log("Time for %s: %.2f" %(message, (splash_end-start2))) message = splash.message() start2 = time.time() else: break except: break status = squish.waitForObject(cvi42Objects.statusBar); while True: if status.currentMessage() == "Load image previews done": break else: pass end = time.time() test.log("Time to Login: %.2f" % (end-start)) return
def click_module(module, ct=False): counter = 0 moduleListItem = "{container=':mWorkflowDockWidget.protocolSteps_Workflow::ProtocolStepListWidget' text='%s' type='QModelIndex'}" % module # If the study is MR, the icon of the selected module is available in the toolbar. Checks if module already selected if ct == False: if object.exists(cvi42Objects.toolbarModuleButton) is True: if squish.waitForObject( cvi42Objects.toolbarModuleButton).text == module: # test.log("Module Already Loaded") return while True: # If module not in the module list, search for it if object.exists(moduleListItem) is False: if counter == 0: # If module list scroll bar available, mouse scroll to try and find module if object.exists(cvi42Objects.moduleListScrollbar): # Mouse scrolls up all the way to see top of visible module list squish.sendEvent( "QWheelEvent", squish.waitForObject(cvi42Objects.moduleListScrollbar), 103, 527, 540, 0, 2) # If module is visible, click it, and exit loop if object.exists(moduleListItem) is True: squish.mouseClick(squish.waitForObject(moduleListItem)) time = loading_time() if time > 10: test.log("Time to load module: %.2f" % time) break # If scroll bar available, scroll down a little bit each iteration squish.sendEvent( "QWheelEvent", squish.waitForObject(cvi42Objects.moduleListScrollbar), 3, 307, -340, 0, 2) # If mouse scroll bar not available, pass each time else: pass counter += 1 # After four attempts, if module is not found, select it from the protocol list and click the module if counter == 4: squish.mouseClick( squish.waitForObject(cvi42Objects.addProtocolButton)) squish.activateItem( squish.waitForObjectItem(cvi42Objects.addProtocolWindow, module)) squish.mouseClick(squish.waitForObject(moduleListItem)) time = loading_time() if time > 10: test.log("Time to load module: %.2f" % time) return # If module exists from the beginning, select it and exit else: squish.mouseClick(squish.waitForObject(moduleListItem)) time = loading_time() if time > 10: test.log("Time to load module: %.2f" % time) return return
def openPOS(self): squish.mouseClick(names.mwi_per_model_btn)
def modifyPOSSetting(self, infill_density): squish.mouseClick(names.field_per_model) self.setTextFieldValue(names.field_per_model, infill_density)
def click(obj, time_out=20000, snooze=200): squish.snooze(snooze / 1000) squish.mouseClick(waitForObject(obj, time_out))
def closeGenericCategory(self): squish.mouseClick(names.mat_general_category_arrow)