[LDTP-Dev] Test scripts

C Shilpa cshilpa at novell.com
Tue Oct 25 03:15:04 PDT 2005


Hi,
I have written 2 test scripts for evolution. Importing a file into
evolution and quitting evolution. For importing a file into evolution, i
have generated the appmap such that the appmap shows everything that is
needed to import a mbox file. That is, in the import dialog, after we
select the file to be imported and click on forward, the dialog changes
depending on the type of file to be imported. The appmap that i have
used is corresponding to the dialog that appears when we try to import
an mbox file. Also I am assuming that the file to be imported is placed
in the home directory.

I have attached both the test scripts. If anything needs to be changed,
please let me know.

Thanks and regards,
Shilpa C.
cshilpa at novell.com
-------------- next part --------------
#!/usr/bin/python
#
#  Linux Desktop Testing Project http://www.gnomebangalore.org/ldtp
# 
#  Author:
#     C Shilpa <cshilpa at novell.com>
# 
#  Copyright 2005 Novell, Inc.
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Library General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
# 
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Library General Public License for more details.
# 
#  You should have received a copy of the GNU Library General Public
#  License along with this library; if not, write to the 
#  Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
#  Boston, MA 02111-1307, USA. 
#
from ldtp import *
from ldtputils import *

#To quit evolution
def quit_evolution ():
    try:
	if guiexist ('frmEvolution-Mail'):
	   str1 = 'frmEvolution-Mail'
	elif guiexist ('frmEvolution-Contacts'):
	   str1 = 'frmEvolution-Contacts'
	elif guiexist ('frmEvolution-Calendars'):
	   str1 = 'frmEvolution-Calendars'
	elif guiexist ('frmEvolution-Tasks'):
	   str1 = 'frmEvolution-Tasks'
	else:
	   log ('Evolution Window does not exist', 'Error')
	   raise LdtpExecutionError (0)

	selectmenuitem (str1, 'mnuFile;mnuQuit')

	#check whether the evolution window has closed
	if waittillguinotexist (str1) == 0:
	   log ('Evolution window does not close' ,'Error')
	   raise LdtpExecutionError (0)
	else:
	   log ('Quitting evolution', 'pass')

    except ldtp.error, msg:
	log ('Quitting evolution failed' + str (msg), 'cause')
	log ('Quitting evolution', 'fail')

#call the function
quit_evolution ()
-------------- next part --------------
#!/usr/bin/python
#
#  Linux Desktop Testing Project http://www.gnomebangalore.org/ldtp
# 
#  Author:
#     C Shilpa <cshilpa at novell.com>
# 
#  Copyright 2005 Novell, Inc.
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Library General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
# 
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Library General Public License for more details.
# 
#  You should have received a copy of the GNU Library General Public
#  License along with this library; if not, write to the 
#  Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
#  Boston, MA 02111-1307, USA. 
#
import time
import string

from ldtp import *
from ldtputils import *

def evolution_import (import_file, import_file_type, location):
    try:
	selectmenuitem ('frmEvolution-Mail', 'mnuFile;mnuImport')
	waittillguiexist ('frmEvolutionImportAssistant')
	if stateenabled ('frmEvolutionImportAssistant', 'btnForward'):
	   click ('frmEvolutionImportAssistant', 'btnForward')
	else:
	   log ('Attempt to import file failed', 'Error')
	   raise LdtpExecutionError (0)
	time.sleep (2)
	check ('frmEvolutionImportAssistant', 'rbtnImportasinglefile')
	#check whether the forward button is enabled
	if stateenabled ('frmEvolutionImportAssistant', 'btnForward'):
	   click ('frmEvolutionImportAssistant', 'btnForward')
	else:
	   log ('Attempt to import file failed', 'Error')
	   raise LdtpExecutionError (0)
	time.sleep (2)
	#selecting the file to be imported from the home directory
	click ('frmEvolutionImportAssistant', 'btnBrowse')
	waittillguiexist ('dlgSelectafile')
	selectrow ('dlgSelectafile', 'tblFiles', import_file)
	click ('dlgSelectafile', 'btnOpen')
	waittillguinotexist ('dlgSelectafile')
	if guiexist ('dlgSelectafile') != 1:
	   log ('Select a file dialog does not close', 'Error')
	   raise LdtpExecutionError (0)
	time.sleep (1)
	#check whether the forward button is activated
	if stateenabled ('frmEvolutionImportAssistant', 'btnForward'):
	   click ('frmEvolutionImportAssistant', 'btnForward')
	else:
	   log ('Unable to import file; Is file format correct ?', 'Error')
	   raise LdtpExecutionError (0)
	time.sleep (2)

	# check what type of file it is, then remap and import the file
	if import_file_type.find ('mail') >= 0:
	   click ('frmEvolutionImportAssistant', 'btnInbox')
	   waittillguiexist ('dlgSelectfolder')
	   #using selectpartialrowmatch in case folder contains unread count
	   selectrowpartialmatch ('dlgSelectfolder', 'ttblMailFolderTree', location)
	   click ('dlgSelectfolder', 'btnOK')
	   waittillguinotexist ('dlgSelectfolder')
	   if guiexist ('dlgSelectfolder') != 1:
		log ('Select Folder dialog does not close', 'Error')
		raise LdtpExecutionError (0)
	elif import_file_type.find ('contact') >= 0:
	   remap ('evolution', 'frmEvolutionImportAssistant')
	   time.sleep (3)
	   selectrowpartialmatch ('frmEvolutionImportAssistant', 'ttbl0', location)
	   undoremap ('evolution', 'frmEvolutionImportAssistant')
	elif import_file_type.find ('calendar') >= 0:
	   remap ('evolution', 'frmEvolutionImportAssistant')
	   time.sleep (3)
	   check ('frmEvolutionImportAssistant', 'rbtnAppointmentsandMeetings')
	   selectrowpartialmatch ('frmEvolutionImportAssistant', 'ttbl0', location)
	   undoremap ('evolution', 'frmEvolutionImportAssistant')
	elif import_file_type.find ('task') >= 0:
	   remap ('evolution', 'frmEvolutionImportAssistant')
	   time.sleep (3)
	   check ('frmEvolutionImportAssistant', 'rbtnTasks')
	   selectrowpartialmatch ('frmEvolutionImportAssistant', 'ttbl0', location)
	   undoremap ('evolution', 'frmEvolutionImportAssistant')
	else:
	   log ('Wrong file type entered', 'Error')
	   raise LdtpExecutionError (0)

	if stateenabled ('frmEvolutionImportAssistant', 'btnForward'):
	   click ('frmEvolutionImportAssistant', 'btnForward')
	else:
	   log ('Attempt to import file failed', 'Error')
	   raise LdtpExecutionError (0)
	time.sleep (2)
	click ('frmEvolutionImportAssistant', 'btnImport')
	if waittillguinotexist ('frmEvolutionImportAssistant') == 0:
	   log ('Import dialog does not close', 'Error')
	   raise LdtpExecutionError (0)
	else:
	   log ('Importing ' + import_file_type + ' file', 'pass')

    except ldtp.error, msg:
	log ('Importing file into evolution failed' + str (msg), 'cause')
	log ('Importing file into evolution', 'fail')

#retrieving values from the data file
data_object = LdtpDataFileParser (datafilename)
import_file = data_object.gettagvalue ('import_file')[0] #path of the file to be imported
import_file_type = data_object.gettagvalue ('import_file_type')[0] #should be mail/contact/calendar/task corresponding to the file type
location = data_object.gettagvalue ('location')[0] #location where to import the file

#call the function
evolution_import (import_file, import_file_type, location)


More information about the Ldtp-dev mailing list