Пример #1
0
def formatMenuShowHide(testcaseId, appName, fileName):
	stepName = "format menu show / hide"
	resultsData = bs_common.getResultsFile()
	
	if target.processes()["Safari"].windows()[fileName]:
		if target.processes()["Safari"].mainWindow().webViews()[0].buttons()["Text"]:
			if target.processes()["Safari"].mainWindow().webViews()[0].elements().firstWithPredicate_("className like 'UIAToolbar'").buttons()["Format"]:
				target.processes()["Safari"].mainWindow().webViews()[0].elements().firstWithPredicate_("className like 'UIAToolbar'").buttons()["Format"].click()
				
				if not target.processes()["Safari"].mainWindow().webViews()[0].buttons()["Text"]:
					target.processes()["Safari"].mainWindow().webViews()[0].elements().firstWithPredicate_("className like 'UIAToolbar'").buttons()["Format"].click()
					
					if target.processes()["Safari"].mainWindow().webViews()[0].buttons()["Text"]:
						bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
						msg = "PASS - "+ stepName
						bs_common.writeToConsole(msg)
						bs_common.writeToLogFile(msg)
										
					else:
						bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
						msg = "FAIL - "+ stepName
						bs_common.transactionFailedExit(msg)
	
	else:
		msg = "FAIL - "+ stepName
		bs_common.writeToConsole(msg)
		bs_common.writeToLogFile(msg)
Пример #2
0
def iCloudSignIn(testcaseId):
	stepName = "icloud sign in"
	if testcaseId is not None:
		configurationData = bs_common.getConfiguration()
		time.sleep(1)
		
		with patience(30):
			target.processes()["Safari"].mainWindow().webViews()[0].textFields()["Apple ID"].isEnabled()
		
		if not target.processes()["Safari"].mainWindow().webViews()[0].textFields()["Apple ID"].isEnabled():
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - "+ stepName
			bs_common.transactionFailedExit(msg)
			
		target.processes()["Safari"].mainWindow().webViews()[0].textFields()["Apple ID"].click()
		keyboard.typeString_(configurationData["iCloudAccount"]["userid"])
		target.processes()["Safari"].mainWindow().webViews()[0].textFields()["Password"].click()
		keyboard.typeString_(configurationData["iCloudAccount"]["password"])
		target.processes()["Safari"].mainWindow().webViews()[0].buttons().firstWithPredicate_("helpTag like 'Sign In'").click()	
		
		with patience(30): target.processes()["Safari"].mainWindow().webViews()[0].images()["iCloud"]
		
		time.sleep(5)
		
		if not target.processes()["Safari"].mainWindow().webViews()[0].images()["iCloud"].isEnabled():
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - "+ stepName
			bs_common.transactionFailedExit(msg)

		else:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
			msg = "PASS - "+ stepName
			bs_common.writeToConsole(msg)
			bs_common.writeToLogFile(msg)
Пример #3
0
def loadGilliganApp(testcaseId, appName):
	stepName = "load gilligan app - "+ appName
	resultsData = bs_common.getResultsFile()
	
	if testcaseId is not None:
		time.sleep(1)	
		if not target.processes()["Safari"].mainWindow().webViews()[0].buttons()[appName].isEnabled() == True:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - "+ stepName
			bs_common.transactionFailedExit(msg)
			
		else:
			target.processes()["Safari"].mainWindow().webViews()[0].buttons()[appName].click()
			
		if not target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts().firstWithPredicate_("name contains '"+ appName +" for iCloud'").isEnabled() == True:
		
			if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("name contains 'Get started with'").isEnabled() == True:
				target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("name contains 'Get started with'").click()
			
			if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts().firstWithPredicate_("name contains 'Choose a Template'").isEnabled() == True:
				target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons().firstWithPredicate_("name contains 'Cancel'").click()
			
			if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].menuItems().firstWithPredicate_("name contains 'Learn More About'").isEnabled() == True:
				target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].buttons()["Show help"].click()	
		
		if target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts().firstWithPredicate_("name contains '"+ appName +" for iCloud'").isEnabled() == True:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
			msg = "PASS - "+ stepName
			bs_common.writeToConsole(msg)
			bs_common.writeToLogFile(msg)
			
		else:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - "+ stepName
			bs_common.transactionFailedExit(msg)
Пример #4
0
def contextMenu_fileExport(testcaseId, appName, inFileName, inExportType):
	stepName = "context menu file export - "+ appName +" / "+ inFileName +" / "+ inExportType
	baseObjectPath = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName]
	resultsData = bs_common.getResultsFile()
	
	if not baseObjectPath.staticTexts().firstWithPredicate_("name like '*"+ inFileName +"*'"):
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
	
	myBounds = baseObjectPath.staticTexts().firstWithPredicate_("name like '*"+ inFileName +"*'").bounds()
	x = Foundation.NSMidX(myBounds)
	y = Foundation.NSMidY(myBounds)
	yOffset = (y - 60)

	keyboard.pressKey_(kVK_Control)
	mouse.click_((x, yOffset))	
	keyboard.releaseKey_(kVK_Control)
	
	myAppFileType = getFileTypeFromAppName(appName)
	
	baseObjectPath.menuItems()["Download "+ myAppFileType +"..."].staticTexts()["Download "+ myAppFileType +"..."].click()
	
	myExportType = getFileExportType(appName, inExportType)
	
	filePattern = re.compile('https://www\.icloud\.com/applications/bight/(.+)/en-us/source/resources/export/(.+)')

	for image in baseObjectPath.images():	
		urlString = image.url()
	
		if urlString is None:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - match "+ appName +" / "+ inFileName +" / "+ inExportType
			bs_common.transactionFailedExit(msg)

		result = filePattern.match(urlString)
		
		if "ubiquityws.icloud.com" in urlString:
# 			This is a document manager object. Skip.			
			continue

		urlExportImage = result.groups()[1]				
		if urlExportImage == myExportType:
			baseObjectPath.images().firstWithPredicate_("url like '"+ urlString +"'").click()
			break
			
	with patience(60): baseObjectPath.buttons()["Cancel\n"].waitForInvalid()
	bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
	msg = "PASS - "+ stepName
	bs_common.writeToConsole(msg)
	bs_common.writeToLogFile(msg)
Пример #5
0
def fileExport(testcaseId, appName, fileName, exportType):
	stepName = "file export - "+ appName +" / "+ fileName +" / "+ exportType
	baseObjectPath = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName]
	resultsData = bs_common.getResultsFile()
	
	if not baseObjectPath.staticTexts().firstWithPredicate_("name like '"+ fileName +"'"):
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
	
	xPoint = baseObjectPath.staticTexts().firstWithPredicate_("name beginswith '"+ fileName +"'").hitpoint().x
	yPoint = baseObjectPath.staticTexts().firstWithPredicate_("name beginswith '"+ fileName +"'").hitpoint().y
	yOffset = (yPoint - 60)

	mouse.click_((xPoint, yOffset))

	baseObjectPath.buttons().firstWithPredicate_("name contains 'Document and Sort Options'").click()
	
	myAppFileType = getFileTypeFromAppName(appName)
	
	baseObjectPath.menuItems()["Download "+ myAppFileType +"..."].staticTexts()["Download "+ myAppFileType +"..."].click()
	
	myExportType = getFileExportType(appName, exportType)
	
	filePattern = re.compile('https://www\.icloud\.com/applications/bight/(.+)/en-us/source/resources/export/(.+)')

	for image in baseObjectPath.images():	
		urlString = image.url()
	
		if urlString is None:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - match "+ appName +" / "+ fileName +" / "+ exportType
			bs_common.transactionFailedExit(msg)

		result = filePattern.match(urlString)
		
		if "ubiquityws.icloud.com" in urlString:
# 			This is a document manager object. Skip.			
			continue

		urlExportImage = result.groups()[1]				
		if urlExportImage == myExportType:
			baseObjectPath.images().firstWithPredicate_("url like '"+ urlString +"'").click()
			break
			
	with patience(60): baseObjectPath.buttons()["Cancel\n"].waitForInvalid()
	bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
	msg = "PASS - "+ stepName
	bs_common.writeToConsole(msg)
	bs_common.writeToLogFile(msg)
Пример #6
0
def fileClose(testcaseId, fileName):
	stepName = "file close - "+ fileName
	if target.processes()["Safari"].windows().firstWithPredicate_("name like '*"+ fileName +"*'"):
		target.processes()["Safari"].windows().firstWithPredicate_("name like '*"+ fileName +"*'").click()
		keyboard.typeString_withModifiersMask_("w", (kUIACommandKeyMask))
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
		msg = "PASS - "+ stepName
		bs_common.writeToConsole(msg)
		bs_common.writeToLogFile(msg)
	
	else:
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
Пример #7
0
def iCloudSignOut(testcaseId):
	stepName = "icloud sign out"
	if testcaseId is not None:
		time.sleep(1)
		if target.processes()["Safari"].windows()["iCloud"].webViews()[0].buttons()["Sign Out"].isEnabled():
			target.processes()["Safari"].windows()["iCloud"].webViews()[0].buttons()["Sign Out"].click()
			
		if target.processes()["Safari"].mainWindow().webViews()[0].textFields()["Apple ID"]:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
			msg = "PASS - "+ stepName
			bs_common.writeToConsole(msg)
			bs_common.writeToLogFile(msg)
	
		else:
			msg = "FAIL - "+ stepName
			bs_common.transactionFailedExit(msg)
Пример #8
0
def fileFindReplace(testcaseId, appName, inFileName, inFindText, inReplaceText):
	stepName = "find '"+ inFindText +"' replace '"+ inReplaceText +"'"
	baseObjectPath = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName]
	resultsData = bs_common.getResultsFile()
	
	if not baseObjectPath.staticTexts().firstWithPredicate_("name beginswith '"+ inFileName +"'"):
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
	
	myBounds = baseObjectPath.staticTexts().firstWithPredicate_("name beginswith '"+ inFileName +"'").bounds()
	x = Foundation.NSMidX(myBounds)
	y = Foundation.NSMidY(myBounds)
	yOffset = (y - 60)

	mouse.doubleClick_((x, yOffset))
Пример #9
0
def exitGilligan(testcaseId, appName):
	stepName = "exit gilligan from - "+ appName
	baseObjectPath = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName]
	resultsData = bs_common.getResultsFile()

	if baseObjectPath.buttons().firstWithPredicate_("helpTag like 'Go to the iCloud home screen'"):
		baseObjectPath.buttons().firstWithPredicate_("helpTag like 'Go to the iCloud home screen'").click()
		
	if target.processes()["Safari"].windows()["iCloud"].webViews()[0].buttons()["Sign Out"].isEnabled():
		bs_common.writeFunctionalTestResults(testcaseId, appName, "PASS")
		msg = "PASS - "+ stepName
		bs_common.writeToConsole(msg)
		bs_common.writeToLogFile(msg)
	
	else:
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
Пример #10
0
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)
Пример #11
0
def createNewFile(testcaseId, appName, fileName):
	stepName = "create new file - "+ appName +" / "+ fileName
	baseObjectPath = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName]
	resultsData = bs_common.getResultsFile()
	
	myFileType = getFileTypeFromAppName(appName)
	
	baseObjectPath.click()
		
	with patience(30): baseObjectPath.staticTexts()["Create "+ myFileType].isEnabled() == True

	if baseObjectPath.staticTexts()["Create "+ myFileType].isEnabled() == True:
		myNewFile = "Create " + myFileType
		hitpointX = baseObjectPath.staticTexts()[myNewFile].hitpoint().x
		hitpointY = baseObjectPath.staticTexts()[myNewFile].hitpoint().y
		hitpointOffsetY = (hitpointY - 90)
		mouse.click_((hitpointX, hitpointOffsetY))	

	else:
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
	
	if not selectGilliganTemplate(appName, fileName):
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
	
	with patience(30):
		target.processes()["Safari"].mainWindow().webViews()[0].staticTexts()["Loading..."].waitForInvalid()
		
	if not target.processes()["Safari"].mainWindow().webViews()[0].elements()[0].buttons().firstWithPredicate_("name contains '%'"):	
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
		
	fileNameToSplit = re.sub(r"([A-Z])", r" \1", fileName).split()
	splitFileName = ' '.join(fileNameToSplit)

	if not baseObjectPath.staticTexts().firstWithPredicate_("name beginswith '"+ splitFileName +"'"):
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
		msg = "FAIL - "+ stepName
		bs_common.transactionFailedExit(msg)
		
	else:
		bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
		msg = "PASS - "+ stepName
		bs_common.writeToConsole(msg)
		bs_common.writeToLogFile(msg)
Пример #12
0
def loadiCloudURL(testcaseId):
	stepName = "load icloud url"
	if testcaseId is not None:	
		if not target.frontProcess().withName_("Safari"):
			target.launchApplication_("Safari")
			time.sleep(1)
			
		if target.processes()["Safari"].mainWindow().toolbar().textFields()[0]:
			target.processes()["Safari"].mainWindow().toolbar().textFields()[0].click()
			keyboard.typeString_("www.icloud.com")
			keyboard.typeVirtualKey_(kVK_Return)
			time.sleep(1)
			
		if target.processes()["Safari"].mainWindow().toolbar().textFields()["Address and Search"].value() == "www.icloud.com":
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")
			msg = "PASS - "+ stepName
			bs_common.writeToConsole(msg)
			bs_common.writeToLogFile(msg)
			
		else:	
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - "+ stepName
			bs_common.transactionFailedExit(msg)
Пример #13
0
def fileRename(testcaseId, appName, fileName, fileRenameTo):
	stepName = "file rename - "+ appName +" / "+ fileName +" to "+ fileRenameTo
	resultsData = bs_common.getResultsFile()
	
	if testcaseId is not None:
		try:
			if not target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts().firstWithPredicate_("name beginswith '"+ fileName +"'"):
				bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
				msg = "FAIL - "+ stepName
				bs_common.writeToConsole(msg)
				bs_common.writeToLogFile(msg)
											
			xPoint = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].images()[0].hitpoint().x
			yPoint = target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].images()[0].hitpoint().y
			yOffset = (yPoint + 125)
			
			mouse.click_((xPoint, yOffset))
	
			keyboard.typeString_(fileRenameTo)
			keyboard.typeVirtualKey_(kVK_Return)
			
			if not target.processes()["Safari"].mainWindow().webViews()[0].webViews()[appName].staticTexts().firstWithPredicate_("name like '"+ fileRenameTo +"'"):
				bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
				msg = "FAIL - "+ stepName
				bs_common.writeToConsole(msg)
				bs_common.writeToLogFile(msg)
				
			else:
				bs_common.writeFunctionalTestResults(testcaseId, stepName, "PASS")	
				msg = "PASS - "+ stepName
				bs_common.writeToConsole(msg)
				bs_common.writeToLogFile(msg)
				
		except:
			bs_common.writeFunctionalTestResults(testcaseId, stepName, "FAIL")
			msg = "FAIL - "+ stepName
			bs_common.transactionFailedExit(msg)