Example #1
0
	def run(self):
		logger.debug("AuthenticateLogin: Started")
		import pywinauto
		pwa_app = pywinauto.application.Application()
		w_handle = None
		logger.debug("AuthenticateLogin: Finding Mozilla login Authentication window")
		for i in range(1,50):
			try:
				w_handle = pywinauto.findwindows.find_windows(title_re=u'Authentication Required', class_name='MozillaDialogClass')[0]
				break
			except:
				time.sleep(1)			
		logger.debug("w_handle is %s" % w_handle)
		if w_handle is None:
			logger.debug("AuthenticateLogin: Windows handle is None")
			from nsUI.actions import get_browser
			browser = get_browser()
			logger.debug("AuthenticateLogin: Killing the browser")
			browser.quit()
			raise Exception("Login Window was not found, so AuthenticateLogin closed the browser.")
		else:
			logger.debug("AuthenticateLogin: Authentication window found.")
			window = pwa_app.window_(handle=w_handle)
			window.SetFocus()
			window.TypeKeys(self.username)
			window.TypeKeys('{TAB}')
			window.TypeKeys(self.pwd)
			window.TypeKeys('{TAB}')
			window.TypeKeys('{ENTER}')
			time.sleep(3)
			logger.debug("AuthenticateLogin: Exiting.")
Example #2
0
	def run(self):
		if platform.system() == "Windows":
			logger.debug("WinFileDownloader: Started")
			import pywinauto
			pwa_app = pywinauto.application.Application()
			w_handle = None
			logger.debug("WinFileDownloader: Finding Mozilla download Dialog window")
			for i in range(1,50):
				try:
					w_handle = pywinauto.findwindows.find_windows(title_re=u'Opening\s+', class_name='MozillaDialogClass')[0]
					break
				except:
					time.sleep(1)				
			logger.debug("w_handle is %s" % w_handle)
			if w_handle is None:
				logger.debug("WinFileDownloader: Windows handle is None")
				from nsUI.actions import get_browser
				browser = get_browser()
				logger.debug("WinFileDownloader: Killing the browser")
				browser.quit()
				raise Exception("Download Window was not found, so WinFileDownloader closed the browser.")
			else:
				logger.debug("WinFileDownloader: Download window found.")
				window = pwa_app.window_(handle=w_handle)
				window.SetFocus()
				window.TypeKeys('%s')
				window = pwa_app.window_(handle=w_handle)
				# window.Click()
				window.SetFocus()
				window.TypeKeys('{TAB}')
				window.TypeKeys('{TAB}')
				window.TypeKeys('{ENTER}')
				time.sleep(15)
				logger.debug("WinFileDownloader: Exiting.")
		else :
			for i in range(50):
				try :
					logger.debug("Finding Download Window %s" %i)
					self.ldtphandler.raw_ldtp.guiexist("frmOpening*")
					time.sleep(5)
					break
				except :
					pass	
			self.ldtphandler.raw_ldtp.grabfocus("frmOpening*", "btnzoombutton")	
			logger.debug("WinFileDownloader: Sending Control + s")
			self.ldtphandler.raw_ldtp.generatekeyevent("<control_l><s>")
			self.ldtphandler.raw_ldtp.grabfocus("frmOpening*", "btnzoombutton")	
			self.ldtphandler.raw_ldtp.generatekeyevent("<enter>")
Example #3
0
	def run(self):
		# logger.debug("winFileUploader: Begins1")
		if platform.system() == "Windows":
			import pywinauto
			logger.debug("Native Windows : Import PyWinAuto")
			# logger.debug("winFileUploader: Begins2")
			pwa_app = pywinauto.application.Application()
			for i in range(1,50):
				logger.debug("Finding. iteration: %d" % (i + 1))
				w_handle = None
				try:
					logger.debug("Native Windows : Title = 'Open'")
					w_handle = pywinauto.findwindows.find_windows(title=u'Open', class_name='#32770')[0]
					break
				except:
					try:
						logger.debug("Native Windows : Title = 'File Upload'")
						w_handle = pywinauto.findwindows.find_windows(title=u'File Upload', class_name='#32770')[0]
						break
					except:
						try:
							logger.debug("Native Windows : Title = 'ChooseFile to Uploads'")
							w_handle = pywinauto.findwindows.find_windows(title=u'Choose File to Upload', class_name='#32770')[0]
							break
						except:
							try:
								logger.debug("Native Windows : Title = 'Select Files to upload'")
								w_handle = pywinauto.findwindows.find_windows(title_re=u'Select\s+file\(s\)\s+to\s+upload by', class_name='#32770')[0]
								break
							except:
								logger.debug("Not found in this cycle")
								time.sleep(1)

			logger.debug("w_handle is %s" % w_handle)
			if w_handle is None:
				logger.debug("WinFileUploader: Windows handle is None")
				from nsUI.actions import get_browser
				browser = get_browser()
				logger.debug("WinFileUploader: Killing the browser")
				browser.quit()
				raise Exception("Upload Window was not found, so WinFileUploader closed the browser.")
			else:
				logger.debug("WinFileUploader: Clicking Edit")
				window = pwa_app.window_(handle=w_handle)
				window.SetFocus()
				ctrl = window['Edit']
				ctrl.Click()
				ctrl = window['Edit']
				logger.debug("WinFileUploader: Sending keys for file path")
				ctrl.TypeKeys(self.file_path)
				time.sleep(3)
				logger.debug("WinFileUploader: Clicking open button")
				ctrl = window['&Open']
				ctrl.SetFocus()
				ctrl.Click()
				logger.debug("WinFileUploader: all done.")
		else :
			import os
			import os.path
			path = os.path.abspath(os.path.join(os.path.dirname(__file__),"..","..","nsUI","util"))
			from nsUI.actions import get_browser
			browser = get_browser()
			windowTitle =  browser.title
			windowTitle = windowTitle.replace(" ","")
			print windowTitle
			browserName = browser.capabilities['browserName'].replace("u","").replace("'","")
			if browserName in "chrome":
				time.sleep(10)
				browserAppName = "Google Chrome"
				time.sleep(5)		
				appleScriptFileFullPath = path + "/macUploadChrome.scpt"
				print appleScriptFileFullPath
				cmd = "osascript %s" %appleScriptFileFullPath
				print os.system(cmd)
				time.sleep(5)
				self.ldtphandler.raw_ldtp.settextvalue("frm%s"%windowTitle, "txttextfield1",self.file_path )
				self.ldtphandler.click_element("Clicking on Go Button", "frm%s"%windowTitle, "btnGo")
				try:
					time.sleep(5)
					self.ldtphandler.click_element("Clicking on Open Button", "frm%s"%windowTitle, "btnOpen")
				except:
					import os.path
					try:
						self.ldtphandler.click_element("Clicking the File ","frm%s"%windowTitle , os.path.basename("img"+self.file_path.replace(".","")))
					except:
						self.ldtphandler.click_element("Clicking the File ","frm%s"%windowTitle , os.path.basename("lst"+self.file_path.replace(".","")))
					self.ldtphandler.click_element("Clicking on Open Button", "frm%s"%windowTitle, "btnOpen")
			elif browserName in 'firefox':
				browserAppName = "Firefox"
				for i in range(15):
					try :
						logger.debug("Finiding Upload Winodw %s" %i)
						self.ldtphandler.raw_ldtp.guiexist("frmFileUpload", "btnCancel")
						time.sleep(5)
						break
					except Exception,e :
						pass
				time.sleep(5)		
				appleScriptFileFullPath = path + "/macUpload.scpt"
				print appleScriptFileFullPath
				cmd = "osascript %s" %appleScriptFileFullPath
				print os.system(cmd)
				time.sleep(5)
				self.ldtphandler.raw_ldtp.settextvalue("frmFileUpload", "txttextfield",self.file_path )
				self.ldtphandler.click_element("Clicking on Go Button", "frmFileUpload", "btnGo")
				self.ldtphandler.click_element("Clicking on Open Button", "frmFileUpload", "btnOpen")
			elif browserName in 'safari':
				browserAppName = "safari"
				time.sleep(5)		
				appleScriptFileFullPath = path + "/macUploadSafari.scpt"
				cmd = "osascript %s" %appleScriptFileFullPath
				os.system(cmd)
				time.sleep(5)
				self.ldtphandler.raw_ldtp.settextvalue("frm%s"%windowTitle, "txttextfield1",self.file_path )
				self.ldtphandler.click_element("Clicking on Go Button", "frm%s"%windowTitle, "btnGo")
				self.ldtphandler.click_element("Clicking on btnChoose Button", "frm%s"%windowTitle, "btnChoose")