def createNewFromTemplate(testcaseId, templateKey, runDataFile): (appName, templateName) = templateKey.split("_") stepName = "create new "+ templateKey if testcaseId is not None: time.sleep(1) fileType = getFileTypeFromAppName(appName) loadGilliganApp(testcaseId, appName) createNewFromFileType = "Create " + fileType hitpointX = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts()[createNewFromFileType].hitpoint().x hitpointY = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts()[createNewFromFileType].hitpoint().y hitpointOffsetY = (hitpointY - 90) mouse.click_((hitpointX, hitpointOffsetY)) startTimer = selectGilliganTemplate(appName, templateName) with patience(60): target.processes()["Safari"].mainWindow().webViews()[0].staticTexts()["Loading..."].waitForInvalid() if target.processes()["Safari"].mainWindow().webViews()[0].elements()[0].buttons().firstWithPredicate_("name contains '%'"): stopTimer = time.time() timingResult = (stopTimer - startTimer) formattedResult = '{0:.3g}'.format(timingResult) bs_common.writePerformanceTestResults(testcaseId, stepName, "PASS", formattedResult) target.processes()["Safari"].mainWindow().click() target.processes()["Safari"].mainWindow().closeButton().click() checkFileSyncing(appName) with patience(30): target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("helpTag like 'Go to the iCloud home screen'").isEnabled() if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("helpTag like 'Go to the iCloud home screen'").isEnabled(): target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("helpTag like 'Go to the iCloud home screen'").click() else: bs_common.writePerformanceTestResults(testcaseId, stepName, "FAIL", 0.00) msg = appName + " '"+ templateName +"' creation failed" bs_common.transactionFailedExit(msg) if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons()["Cancel"].isEnabled(): bs_common.writePerformanceTestResults(testcaseId, stepName, "FAIL", 0.00) msg = "Something is wrong. Should not see the template screen" bs_common.transactionFailedExit(msg) if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].groups().firstWithPredicate_("helpTag contains 'Try again later'"): bs_common.writePerformanceTestResults(testcaseId, stepName, "FAIL", 0.00) msg = appName + " '"+ templateName +"' Received 'Could not be Created' dialog" bs_common.transactionFailedExit(msg) target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].groups().firstWithPredicate_("helpTag contains 'Try again later'").buttons()["OK"].click() target.processes()["Safari"].mainWindow().click() target.processes()["Safari"].mainWindow().closeButton().click() with patience(45): target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("helpTag like 'Go to the iCloud home screen'").isEnabled() == True target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("helpTag like 'Go to the iCloud home screen'").click() bs_common.writeItemStatus(runDataFile, templateKey, 1)
def createNewFromTemplate(testcaseId, templateKey, runDataFile): (appName, templateName) = templateKey.split("_") stepName = "new from template '"+ templateKey +"'" baseObjectPath = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName] fileType = getFileTypeFromAppName(appName) time.sleep(1) loadGilliganApp(testcaseId, appName) time.sleep(1) createNewFromFileType = "Create " + fileType myBounds = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts()[createNewFromFileType].bounds() x = Foundation.NSMidX(myBounds) y = Foundation.NSMidY(myBounds) yOffset = (y - 90) mouse.click_((x, yOffset)) startTimer = selectGilliganTemplate(appName, templateName) with patience(60): target.processes()["Safari"].mainWindow().webViews()[0].staticTexts()["Loading..."].waitForInvalid() if target.processes()["Safari"].mainWindow().webViews()[0].elements()[0].buttons().firstWithPredicate_("name contains '%'"): stopTimer = time.time() timingResult = (stopTimer - startTimer) formattedResult = '{0:.3g}'.format(timingResult) bs_common.writePerformanceTestResults(testcaseId, stepName, "PASS", formattedResult) target.processes()["Safari"].mainWindow().click() target.processes()["Safari"].mainWindow().closeButton().click() else: bs_common.writePerformanceTestResults(testcaseId, stepName, "FAIL", 0.00) msg = "FAIL - "+ appName + " '"+ templateName +"' creation failed" bs_common.scriptFailedExit(msg) checkFileSyncing(appName) validateObject = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons()["Go to the iCloud home screen"] validateResult = bs_common.validateObject(validateObject) if not validateResult: bs_common.writeResults(testcaseId, stepName, "FAIL") msg = "FAIL - bs_common.validateObject: "+ validateObject bs_common.scriptFailedExit(msg) target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons()["Go to the iCloud home screen"].click() if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons()["Cancel"].isEnabled(): bs_common.writePerformanceTestResults(testcaseId, stepName, "FAIL", 0.00) msg = "FAIL - Something is wrong. Should not see the template screen" bs_common.scriptFailedExit(msg) if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].groups().firstWithPredicate_("helpTag contains 'Try again later'"): bs_common.writePerformanceTestResults(testcaseId, stepName, "FAIL", 0.00) msg = "FAIL - "+ appName + " '"+ templateName +"' Received 'Could not be Created' dialog" bs_common.scriptFailedExit(msg) target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].groups().firstWithPredicate_("helpTag contains 'Try again later'").buttons()["OK"].click() target.processes()["Safari"].mainWindow().click() target.processes()["Safari"].mainWindow().closeButton().click() validateObject = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons()["Go to the iCloud home screen"] validateResult = bs_common.validateObject(validateObject) if not validateResult: bs_common.writeResults(testcaseId, stepName, "FAIL") msg = "FAIL - bs_common.validateObject: "+ validateObject bs_common.scriptFailedExit(msg) target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons()["Go to the iCloud home screen"].click() bs_common.writeItemStatus(runDataFile, templateKey, 1)