Best Python code snippet using pyatom_python
addmeeting.py
Source:addmeeting.py
1#!/usr/bin/env python2#3# Linux Desktop Testing Project http://ldtp.freedesktop.org4#5# Author:6# Prashanth Mohan <prashmohan@gmail.com>7#8# Copyright 2004 Novell, Inc.9#10# This test script is free software; you can redistribute it and/or11# modify it under the terms of the GNU Library General Public12# License as published by the Free Software Foundation; either13# version 2 of the License, or (at your option) any later version.14#15# This library is distributed in the hope that it will be useful,16# but WITHOUT ANY WARRANTY; without even the implied warranty of17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU18# Library General Public License for more details.19#20# You should have received a copy of the GNU Library General Public21# License along with this library; if not, write to the22# Free Software Foundation, Inc., 59 Temple Place - Suite 330,23# Boston, MA 02111-1307, USA.24#25from ldtp import *26from ldtputils import *27from contact import *28from evoutils.calendar import *29def addmeeting(datafilename,recur):30 log ('Add New Meeting','teststart')31 try:32 addrbook, summary, location, description, from_date, to_date, from_time, to_time, calendar, classification, categories, exception, attendee, email, duration, dur_value, dur_day, count, for_type, no_of_times = getmeetingdata (datafilename)33 print addrbook, summary, location, description, from_date, to_date, from_time, to_time, calendar, classification, categories, exception, attendee, email, duration, dur_value, dur_day, count, for_type, no_of_times34 selectCalendarPane()35 time.sleep (3)36 selectmenuitem ('frmEvolution-Calendars','mnuFile;mnuNew;mnuMeeting')37 windowname = 'frmMeeting-*'38 waittillguiexist (windowname)39 time.sleep (1)40 menuuncheck (windowname, 'mnuOptions;mnuAllDayEvent')41 remap ('evolution',windowname)42 try:43 definemeeting (summary, location, description, from_date, to_date, from_time, to_time, calendar, classification, categories)44 except:45 log ('Could not add main values for meeting','error')46 raise LdtpExecutionError(0)47 addattendees (attendee,email,addrbook)48 time.sleep (2)49 try:50 if recur==1 or len(exception)>0:51 selectmenuitem (windowname, 'mnuOptions;mnuRecurrence')52 waittillguiexist ('dlgRecurrence')53 time.sleep (4)54 insert_recurrence ('dlgRecurrence',duration[0],dur_value[0],55 dur_day[0],count[0],for_type[0],56 no_of_times[0],exception)57 except:58 raise LdtpExecutionError(0)59 click (windowname,'btnSave')60 if waittillguiexist ('dlgEvolutionQuery') != 0:61 click ('dlgEvolutionQuery','btnDonotSend')62 time.sleep (3)63 except:64 log ('Could not add New meeting','error')65 log ('Add New Meeting','testend')66 raise LdtpExecutionError (0)67 try:68 verifymeeting(summary,location,description,from_date,to_date,from_time,69 to_time,calendar,classification,categories,exception,70 attendee,email,duration,dur_value,dur_day,count,for_type,71 no_of_times)72 except:73 log ('Verification Failed', 'cause')74 log ('Add New Meeting','testend')75 raise LdtpExecutionError (0)76 log ('Add New Meeting','testend')77 78def getmeetingdata(datafilename):79 log ('Getting Values for New Meeting','teststart')80 try:81 data_object = LdtpDataFileParser (datafilename)82 addrbook = data_object.gettagvalue ('addrbook')83 summary = data_object.gettagvalue ('summary')84 location = data_object.gettagvalue ('location')85 description = data_object.gettagvalue ('description')86 from_date = data_object.gettagvalue ('from_date')87 to_date = data_object.gettagvalue ('to_date')88 from_time = data_object.gettagvalue ('from_time')89 to_time = data_object.gettagvalue ('to_time')90 calendar = data_object.gettagvalue ('calendar')91 classification = data_object.gettagvalue ('classification')92 categories = data_object.gettagvalue ('categories')93 exception = data_object.gettagvalue ('exception')94 index = 195 attendee = []96 email = []97 while True:98 att = data_object.gettagvalue ('attendee'+str(index))99 em = data_object.gettagvalue ('email'+str(index))100 if att == [] or em == []:101 break102 attendee.append (att[0])103 email.append (em[0])104 index += 1105 duration = data_object.gettagvalue ('duration')106 dur_value = data_object.gettagvalue ('durvalue')107 dur_day = data_object.gettagvalue ('durday')108 count = data_object.gettagvalue ('count')109 for_type = data_object.gettagvalue ('fortype')110 no_of_times = data_object.gettagvalue ('nooftimes')111 except:112 log ('Error While getting Values','error')113 log ('Getting Values for New Meeting','testend')114 raise LdtpExecutionError(0)115 log ('Getting Values for New Meeting','testend')116 print addrbook,summary,location,description,from_date,to_date,from_time,to_time,calendar,classification,categories,exception,attendee,email,duration,dur_value,dur_day,count,for_type,no_of_times117 return addrbook,summary,location,description,from_date,to_date,from_time,to_time,calendar,classification,categories,exception,attendee,email,duration,dur_value,dur_day,count,for_type,no_of_times118def addattendees(attendee,email,addrbook):119 log ('Add Attendees','teststart')120 try:121 window_id = 'frmMeeting-*'122 click (window_id,'btnAttendees')123 waittillguiexist ('dlgRequiredParticipants')124 time.sleep (1)125 comboselect ('dlgRequiredParticipants','cboAddressBook',addrbook[0])126 remap ('evolution','dlgRequiredParticipants')127 #attendee=attendee[0].split (':')128 #email=email[0].split (':')129 print attendee, email130 if len(attendee)!=len(email):131 log ('Mismatch in Attendee name and email','error')132 raise LdtpExecutionError (0)133 for ind in range(len(attendee)):134 try:135 att = parsename(attendee[ind],email[ind])136 print att,"Inside for loop"137 if gettablerowindex ('dlgRequiredParticipants','tblRequiredParticipants',att)==-1:138 print "inside if"139 selectrowpartialmatch ('dlgRequiredParticipants','tblContacts',att)140 print "row selected"141 click ('dlgRequiredParticipants', 'btnAdd1')142 time.sleep (1)143 except:144 log ('User not found','cause')145 raise LdtpExceptionError(0)146 click ('dlgRequiredParticipants', 'btnClose')147 #undoremap ('evolution','dlgRequiredParticipants')148 except:149 log ('Attendee Addition failed','error')150 log ('Add Attendees','testend')151 raise LdtpExecutionError (0)152 log ('Add Attendees','testend')153 154def verimeetattendees(attendee,email):155 try:156 click ('frmMeeting-Nosummary','btnAttendees')157 waittillguiexist ('dlgRequiredParticipants')158 attendee=attendee.split (' ')159 email=email.split (' ')160 for ind in len(attendee):161 att=parsename(attendee[ind],email[ind])162 if gettablerowindex ('dlgRequiredParticipants','tblRequiredParticipants',att)==-1:163 log ('User Not found','cause')164 raise LdtpExceptionError(0)165 click ('dlgRequiredParticipants', 'btnClose')166 except:167 raise LdtpExecutionError (0)168def parsename (attendee,email):169 name=attendee170 name=name+' <'+email+'>'171 return name172def verifymeeting(summary,location,description,from_date,to_date,from_time,to_time,calendar,classification,categories,exception,attendee,email,duration,dur_value,dur_day,count,for_type,no_of_times):173 log ('Verify Added Meeting','teststart')174 try:175 try:176 print from_date177 print summary178 except:179 print 'from_date, summary not available'180 selectcalevent (from_date[0],summary[0])181 time.sleep (2)182 selectmenuitem ('frmEvolution-Calendars','mnuFile;mnuOpenAppointment')183 window_id = 'frmMeeting-*'184 time.sleep (3)185 waittillguiexist (window_id)186 verimeetmainwindow(summary,location,description,from_date,to_date,from_time,187 to_time,calendar,classification,categories)188 #verimeetattendees (attendee,email)189 if duration or dur_value or dur_day or count or for_type or no_of_times:190 selectmenuitem (window_id,'mnuOptions;mnuRecurrence')191 waittillguiexist ('dlgRecurrence')192 verify_recurrence ('dlgRecurrence', duration, dur_value, dur_day, count,193 for_type, no_of_times, exception)194 waittillguinotexist ('dlgRecurrence')195 selectmenuitem (window_id,'mnuFile;mnuClose')196 except:197 log ('Meeting not Verified','error')198 log ('Verify Added Meeting','testend')199 selectmenuitem (window_id,'mnuFile;mnuClose')200 raise LdtpExecutionError (0)201 log ('Verify Added Meeting','testend')202def verimeetmainwindow(summary,location,description,from_date,to_date,from_time,to_time,calendar,classification,categories):203 try:204# if verifysettext ('frmMeeting-Nosummary','cboCalendar',calendar[0])==0:205# log ('Calendar not set properly','cause')206# raise LdtpExecutionError(0)207 window_id = 'frmMeeting-*'208 if verifysettext (window_id,'txtSummary',summary[0])==0:209 log ('Summary not set properly','cause')210 raise LdtpExecutionError(0)211 print location[0]212 if len(location)>0 and verifysettext (window_id,'txtLocation',location[0])==0:213 log ('Location not set properly','cause')214 raise LdtpExecutionError(0)215 if verifysettext (window_id,'txtDescription',description[0])==0:216 log ('Description not set properly','cause')217 raise LdtpExecutionError(0)218# if len(from_date)>0 and verifysettext ('frmMeeting-Nosummary','txtTextDateEntry',from_date[0])==0:219# log ('From Date not set properly','cause')220# raise LdtpExecutionError(0)221# if len(to_date)>0 and verifysettext ('frmMeeting-Nosummary','txtTextDateEntry1',to_date[0])==0:222# log ('To-Date not set properly','cause')223# raise LdtpExecutionError(0)224# if len(from_time)>0 and verifysettext ('frmMeeting-Nosummary','txt3',from_time[0])==0:225# log ('From-Time not set properly','cause')226# raise LdtpExectionError(0)227# if len(to_time)>0 and verifysettext ('frmMeeting-Nosummary','txt5',to_time[0])==0:228# log ('To-Time not set properly','cause')229# raise LdtpExecutionError(0)230 if len(categories)>0 and verifysettext (window_id,'txtCategories',categories[0])==0:231 log ('Categories not set properly','cause')232 raise LdtpExecutionError(0)233 except:234 raise LdtpExecutionError(0)235def definemeeting(summary,location,description,from_date,to_date,from_time,to_time,calendar,classification,categories):236 log ('Define meeting values','teststart')237 try:238 time.sleep (2)239 window_id = 'frmMeeting-*'240 try:241 menuuncheck (window_id,'mnuOptions;mnuAllDayEvent')242 comboselect (window_id,'cboCalendar',calendar[0])243 except:244 log ('Calendar not present','cause')245 raise LdtpExecutionError(0)246 settextvalue (window_id,'txtSummary',summary[0])247 print "Setting Sumary Over"248 if len(location)>0:249 settextvalue (window_id,'txtLocation',location[0])250 print "Setting Location Over"251 if len (description)>0:252 settextvalue (window_id,'txtDescription',description[0])253 print "Setting Desc Over"254 if len(from_date)>0:255 settextvalue (window_id,'txtDate',from_date[0])256 time.sleep (2)257 if guiexist ('*Warning') == 1:258 log ('Error in input date format','cause')259 click ('*Warning','btnOK')260 raise LdtpExecutionError (0)261 print "Setting from date Over"262 if len (to_date)>0:263 comboselect (window_id, 'cbofor','until')264 settextvalue (window_id,'txtDate1',to_date[0])265 time.sleep (2)266 if guiexist ('*Warning') == 1:267 log ('Error in input date format','cause')268 click ('*Warning','btnOK')269 raise LdtpExecutionError (0)270 271 print "Setting TO DATE Over"272 if len(from_time)>0:273 settextvalue (window_id,'txt3',from_time[0])274 time.sleep (2)275 if guiexist ('*Warning') == 1:276 log ('Error in input date format','cause')277 click ('*Warning','btnOK')278 raise LdtpExecutionError (0)279 print "Setting from time Over"280 if len(to_time)>0:281 settextvalue (window_id,'txt5',to_time[0])282 time.sleep (2)283 if guiexist ('*Warning') == 1:284 log ('Error in input date format','cause')285 click ('*Warning','btnOK')286 raise LdtpExecutionError (0)287 288 print "Setting to time Over"289 try:290 selectmenuitem (window_id,'mnuOptions;mnuClassification;mnu'+classification[0])291 print "Classification menu is special"292 except:293 log ('Classification incorrectly specified','cause')294 raise LdtpExecutionError(0)295 if len (categories)>0:296 menucheck (window_id,'mnuEdit;mnuCategories')297 remap ('evolution',window_id)298 settextvalue (window_id,'txtCategories',categories[0])299 print "Setting Categories Over"300 except:301 log ('Define Meeting values failed','error')302 log ('Define meeting values','testend')303 raise LdtpExecutionError(0)...
text.py
Source:text.py
1#!/usr/bin/env python2#3# Linux Desktop Testing Project http://www.gnomebangalore.org/ldtp4#5# Description:6# This set of test scripts will test the LDTP framework for correct7# functioning of its APIs. This is a Regression Suite.8#9# Author:10# Prashanth Mohan <prashmohan@gmail.com>11#12#13# This test script is free software; you can redistribute it and/or14# modify it under the terms of the GNU Library General Public15# License as published by the Free Software Foundation; either16# version 2 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Library General Public License for more details.22#23# You should have received a copy of the GNU Library General Public24# License along with this library; if not, write to the25# Free Software Foundation, Inc., 59 Temple Place - Suite 330,26# Boston, MA 02111-1307, USA.27#28from regression import *29import random, os30try:31 check_open('gedit')32except:33 raise34data_object = LdtpDataFileParser (datafilename)35text = data_object.gettagvalue ('text')36insert_text = data_object.gettagvalue ('inserttext')37insert_pos = data_object.gettagvalue ('insertpos')38cut_start = data_object.gettagvalue ('cutstart')39cut_stop = data_object.gettagvalue ('cutstop')40delete_start = data_object.gettagvalue ('deletestart')41delete_stop = data_object.gettagvalue ('deletestop')42if text == []:43 text = 'This is the default text for the LDTP Regression Suite'44else:45 text = text[0]46if insert_text == []:47 insert_text = text48else:49 insert_text = insert_text[0]50if insert_pos == []:51 insert_pos = 052else:53 insert_pos = int(insert_pos[0])54if cut_start == []:55 cut_start = 056else:57 cut_start = int(cut_start[0])58 59try:60 check_open('gedit')61except:62 raise63log ('settextvalue','teststart')64try:65 if settextvalue ('*gedit','txt0',text) == 0:66 raise LdtpExecutionError (str (traceback.format_exc ()))67 if verifysettext ('*gedit','txt0',text) == 0:68 raise LdtpExecutionError (str (traceback.format_exc ()))69except:70 testfail ('settextvalue')71 raise LdtpExecutionError (str (traceback.format_exc ()))72testpass ('settextvalue')73log ('gettextvalue','teststart')74try:75 present_text = gettextvalue ('*gedit','txt0')76 if present_text != text:77 raise LdtpExecutionError (str (traceback.format_exc ()))78except:79 testfail ('gettextvalue')80 raise LdtpExecutionError (str (traceback.format_exc ()))81testpass ('gettextvalue')82log ('verifysettext','teststart')83try:84 present_text = gettextvalue ('*gedit','txt0')85 if verifysettext ('*gedit','txt0',present_text) != 1:86 log ('Text present but says not present','cause')87 raise LdtpExecutionError (str (traceback.format_exc ()))88 if verifysettext ('*gedit','txt0',present_text+'123') != 0:89 log ('Text not present but says present','cause')90 raise LdtpExecutionError (str (traceback.format_exc ()))91 if verifysettext ('*gedit','txt0',present_text[:-1]) != 0:92 log ('Text not present but says present','cause')93 raise LdtpExecutionError (str (traceback.format_exc ()))94 # http://bugzilla.gnome.org/show_bug.cgi?id=351227 95# if verifysettext ('*gedit','txt0','') != 0 and present_text != '':96# log ('Text not present but says present','cause')97# raise LdtpExecutionError (str (traceback.format_exc ()))98except:99 testfail ('verifysettext')100 raise LdtpExecutionError (str (traceback.format_exc ()))101testpass('verifysettext')102 103log ('stateenabled','teststart')104try:105 if istextstateenabled ('*gedit','txt0') == 0:106 log ('State Disabled','info')107 raise LdtpExecutionError (str (traceback.format_exc ()))108 else:109 log ('State Enabled','info')110except:111 testfail ('stateenbled')112 raise LdtpExecutionError (str (traceback.format_exc ()))113testpass ('stateenbled')114log ('appendtext','teststart')115try:116 present_text = gettextvalue ('*gedit','txt0')117 if appendtext ('*gedit','txt0',text) == 0:118 raise LdtpExecutionError (str (traceback.format_exc ()))119 if gettextvalue ('*gedit','txt0') != present_text+text:120 raise LdtpExecutionError (str (traceback.format_exc ()))121except:122 testfail ('appendtext')123 raise LdtpExecutionError (str (traceback.format_exc ()))124testpass ('appendtext')125log ('getcharactercount','teststart')126try:127 present_text = gettextvalue ('*gedit','txt0')128 if getcharcount ('*gedit','txt0') != len(present_text):129 raise LdtpExecutionError (str (traceback.format_exc ()))130except:131 testfail ('getcharactercount')132 raise LdtpExecutionError (str (traceback.format_exc ()))133testpass ('getcharactercount')134log ('getcursorposition','teststart')135try:136 if getcharcount ('*gedit','txt0') != getcursorposition ('*gedit','txt0'):137 raise LdtpExecutionError (str (traceback.format_exc ()))138except:139 testfail ('getcursorposition')140 raise LdtpExecutionError (str (traceback.format_exc ()))141testpass ('getcursorposition')142if len (present_text) < insert_pos:143 new_text = present_text+insert_text144else:145 new_text = present_text[:insert_pos]+insert_text+present_text[insert_pos:]146log ('inserttext','teststart')147try:148 if inserttext ('*gedit', 'txt0', insert_pos, insert_text) == 0:149 raise LdtpExecutionError (str (traceback.format_exc ()))150 if gettextvalue ('*gedit','txt0') != new_text:151 raise LdtpExecutionError (str (traceback.format_exc ()))152except:153 testfail ('inserttext')154 raise LdtpExecutionError (str (traceback.format_exc ()))155testpass ('inserttext')156 157log ('cuttext','teststart')158try:159 if cut_stop == []:160 cut_stop = getcharactercount ('*gedit','txt0')161 else:162 cut_stop = int(cut_stop[0])163 present_text = gettextvalue ('*gedit','txt0')164 length = getcharcount ('*gedit','txt0')165 if cut_stop < cut_start or cut_start > length or cut_stop > length:166 log ('Input not proper','cause')167 raise LdtpExecutionError (str (traceback.format_exc ()))168 new_text = present_text[:cut_start]+present_text[cut_stop:]169 cut_text = present_text[cut_start:cut_stop]170 if cuttext ('*gedit','txt0',cut_start, cut_stop) == 0:171 raise LdtpExecutionError (str (traceback.format_exc ()))172 if gettextvalue ('*gedit','txt0') != new_text:173 raise LdtpExecutionError (str (traceback.format_exc ()))174except:175 testfail ('cuttext')176 raise LdtpExecutionError (str (traceback.format_exc ()))177testpass ('cuttext')178log ('pastetext','teststart')179try:180 present_text = gettextvalue ('*gedit','txt0')181 new_text = present_text[:cut_start]+cut_text+present_text[cut_start:]182 if pastetext ('*gedit','txt0',cut_start) == 0:183 raise LdtpExecutionError (str (traceback.format_exc ()))184 if gettextvalue ('*gedit','txt0') != new_text:185 raise LdtpExecutionError (str (traceback.format_exc ()))186except:187 testfail ('pastetext')188 raise LdtpExecutionError (str (traceback.format_exc ()))189testpass ('pastetext')190log ('copytext','teststart')191try:192 length = getcharcount ('*gedit','txt0')193 if cut_stop < cut_start or cut_start > length:194 log ('Input not proper','cause')195 raise LdtpExecutionError (str (traceback.format_exc ()))196 if cut_stop > length:197 cut_stop = length-1198 199 present_text = gettextvalue ('*gedit','txt0')200 copy_text = present_text[cut_start:cut_stop]201 202 if copytext ('*gedit','txt0',cut_start, cut_stop) == 0:203 raise LdtpExecutionError (str (traceback.format_exc ()))204 if gettextvalue ('*gedit','txt0') != present_text:205 raise LdtpExecutionError (str (traceback.format_exc ()))206except:207 testfail ('copytext')208 raise LdtpExecutionError (str (traceback.format_exc ()))209testpass ('copytext')210log ('pastetext','teststart')211try:212 present_text = gettextvalue ('*gedit','txt0')213 new_text = present_text[:cut_start]+copy_text+present_text[cut_start:]214 if pastetext ('*gedit','txt0',cut_start) == 0:215 raise LdtpExecutionError (str (traceback.format_exc ()))216 if gettextvalue ('*gedit','txt0') != new_text:217 raise LdtpExecutionError (str (traceback.format_exc ()))218except:219 testfail ('pastetext')220 raise LdtpExecutionError (str (traceback.format_exc ()))221testpass ('pastetext')222log ('deletetext','teststart')223try:224 length = getcharcount ('*gedit','txt0')225 present_text = gettextvalue ('*gedit','txt0')226 if delete_start == []:227 delete_start = 0228 else:229 delete_start = int (delete_start[0])230 if delete_stop == []:231 if delete_start+1 <= length:232 log ('Not enough text on screen','cause')233 raise LdtpExecutionError (str (traceback.format_exc ()))234 delete_stop = delete_start + 1235 else:236 delete_stop = int (delete_stop[0])237 238 if delete_stop < delete_start or delete_start > length or delete_stop > length:239 log ('Input not proper','cause')240 raise LdtpExecutionError (str (traceback.format_exc ()))241 242 new_text = present_text[:delete_start]+present_text[delete_stop:]243 if deletetext ('*gedit','txt0',delete_start, delete_stop) == 0:244 raise LdtpExecutionError (str (traceback.format_exc ()))245 if gettextvalue ('*gedit','txt0') != new_text:246 raise LdtpExecutionError (str (traceback.format_exc ()))247except:248 testfail ('deletetext')249 raise LdtpExecutionError (str (traceback.format_exc ()))250testpass ('deletetext')251log ('cursorposition','teststart') #tests for getcursorposition and setcursorposition252try:253 length = getcharcount ('*gedit','txt0')254 setcursorposition ('*gedit','txt0',0)255 if getcursorposition ('*gedit','txt0') != 0:256 log ('Unable to Set Cursor position to 0','cause')257 raise LdtpExecutionError (str (traceback.format_exc ()))258 if length == 0:259 val = 0260 else:261 val = length - 1262 setcursorposition ('*gedit','txt0',val)263 if getcursorposition ('*gedit','txt0') != val:264 log ('Unable to Set Cursor position to end of sentence','cause')265 raise LdtpExecutionError (str (traceback.format_exc ()))266 val = length/2267 setcursorposition ('*gedit','txt0',val)268 if getcursorposition ('*gedit','txt0') != val:269 log ('Unable to Set Cursor position to middle of sentence','cause')270 raise LdtpExecutionError (str (traceback.format_exc ()))271except:272 testfail ('cursorposition')273 raise LdtpExecutionError (str (traceback.format_exc ()))274testpass ('cursorposition')275log ('verifypartialmatch','teststart')276try:277 present_text = gettextvalue ('*gedit','txt0')278 length = len (present_text)279 middle = random.randint (0,length-1)280 if verifypartialmatch ('*gedit','txt0',281 present_text[middle:random.randint (middle, length-1)]) != 1:282 log ('Does not do correct matching','cause')283 raise LdtpExecutionError (str (traceback.format_exc ()))284 if verifypartialmatch ('*gedit','txt0',text+'123') != 0:285 log ('Does not check for overflow','cause')286 raise LdtpExecutionError (str (traceback.format_exc ()))287 if verifypartialmatch ('*gedit','txt0','123'+text) != 0:288 log ('Does not check for overflow','cause')289 raise LdtpExecutionError (str (traceback.format_exc ()))290except:291 testfail ('cursorposition')292 raise LdtpExecutionError (str (traceback.format_exc ()))293testpass ('cursorposition')294log ('selecttextbyname','teststart')295try:296 selecttextbyname ('*gedit','txt0')297 ## FIXME :: Find a way to verify this!!!298 setcursorposition ('*gedit','txt0',0)299except:300 testfail ('selecttextbyname')301 raise LdtpExecutionError (str (traceback.format_exc ()))302testpass ('selecttextbyname')303 304## FIXME :: Add test for text properties -- gettextproperty and comparetextproperty305# try:306# close_gedit()307# except:...
task.py
Source:task.py
1from ldtp import *2from ldtputils import *3from contact import *4from evoutils import *5from evoutils.calendar import get_date_format6def gettaskdata(datafilename):7 data_object = LdtpDataFileParser (datafilename)8 Group = data_object.gettagvalue ('group')9 Summary = data_object.gettagvalue ('summary')10 Desc = data_object.gettagvalue ('desc')11 Start_date = data_object.gettagvalue ('start_date')12 Start_time = data_object.gettagvalue ('start_time')13 End_date = data_object.gettagvalue ('end_date')14 End_time = data_object.gettagvalue ('end_time')15 Time_zone = data_object.gettagvalue ('time_zone')16 Categories = data_object.gettagvalue ('Categories')17 return Group, Summary, Desc, Start_date, Start_time, End_date, End_time, Time_zone, Categories18def fill_task (Group, Summary, Desc, Start_date, Start_time, End_date, End_time, Time_zone, Categories, window_id = 'frmTask-*'):19 try:20# for obj in getobjectlist ('frmTask-*'):21# if obj.startswith ('cbo'):22# grp_obj = obj23# break24 grp_obj = 'cboPersonal'25 if Group:26 comboselect (window_id, grp_obj, Group[0])27 time.sleep(3)28 settextvalue (window_id, 'txtSummary', Summary[0])29 if Desc:30 settextvalue (window_id, 'txtDescription', Desc[0])31 if Start_date:32 settextvalue (window_id, 'txtDate1',Start_date[0])33 if End_date:34 settextvalue (window_id, 'txtDate',End_date[0])35 if Start_time:36 settextvalue (window_id, 'txt8',Start_time[0])37 if End_time:38 settextvalue (window_id, 'txt6',End_time[0])39 #if Time_zone:40 # menucheck (window_id,'mnuView;mnuTimeZone')41 # settextvalue (window_id, 'txt4',Time_zone[0])42 #else:43 menuuncheck (window_id,'mnuView;mnuTimeZone')44 if Categories:45 menucheck (window_id,'mnuView;mnuCategories')46 settextvalue (window_id, 'txt0',Categories[0])47 else:48 menuuncheck (window_id,'mnuView;mnuCategories')49 log('User Details entered','info')50 except:51 print 'Error in entering the values'52 log('Error in entering the values','error')53 raise LdtpExecutionError(0)54 55def verify_task (Group, Summary, Desc, Start_date, Start_time, End_date,56 End_time, Time_zone, Categories, windowname='frmTask-*'):57 try:58 selectmenuitem ('frmEvolution-Tasks','mnuFile;mnuOpenTask');59 if waittillguiexist (windowname) == 0:60 log ('Unable to open Task','cause')61 raise LdtpExecutionError (0)62 63 if Desc and verifysettext (windowname, 'txtDescription', Desc[0]) == 0:64 log ('Description not set','cause')65 raise LdtpExecutionError (0)66 67 # if Start_date and verifysettext (windowname, 'txtDate1',get_date_format(Start_date[0])) == 0:68 # log ('Start Date set incorrectly','cause')69 # raise LdtpExecutionError (0)70 # if End_date and verifysettext (windowname, 'txtDate',get_date_format(End_date[0])) == 0:71 # log ('End date set incorrectly','cause')72 # raise LdtpExecutionError (0)73 74 if Start_time and verifysettext (windowname, 'txt8',Start_time[0]) == 0:75 log ('Start time set incorrectly','cause')76 raise LdtpExecutionError (0)77 78 if End_time and verifysettext (windowname, 'txt6',End_time[0]) == 0:79 log ('End time set incorrectly','cause')80 raise LdtpExecutionError (0)81 82 # if Time_zone and verifysettext (windowname, 'txt4',Time_zone[0]) == 0:83 # log ('Time Zone set incorrecly','cause')84 # raise LdtpExecutionError (0)85 86 if Categories and verifysettext (windowname, 'txt0',Categories[0]) == 0:87 log ('Categories set incorrectly','cause')88 raise LdtpExecutionError (0)89 except:90 log ('Task Verification failed','error')91 raise LdtpExecutionError (0)92 93def read_assignedtask_data (datafilename):94 try:95 data_object = LdtpDataFileParser (datafilename)96 index = 197 attendee = []98 email = []99 while True:100 att = data_object.gettagvalue ('attendee'+str(index))101 em = data_object.gettagvalue ('email'+str(index))102 103 if att == [] or em == []:104 break105 attendee.append (att[0])106 email.append (em[0])107 index += 1108 addr_book = data_object.gettagvalue ('addr_book')109 Group = data_object.gettagvalue ('group')110 Summary = data_object.gettagvalue ('summary')111 Desc = data_object.gettagvalue ('Desc')112 Start_date = data_object.gettagvalue ('start_date')113 Start_time = data_object.gettagvalue ('start_time')114 End_date = data_object.gettagvalue ('due_date')115 End_time = data_object.gettagvalue ('due_time')116 Time_zone = data_object.gettagvalue ('time_zone')117 Categories = data_object.gettagvalue ('Categories')118 print Group, Summary, Desc, Start_date, Start_time, \119 End_date, End_time, Time_zone, Categories, attendee, email120 return Group, Summary, Desc, Start_date, Start_time, \121 End_date, End_time, Time_zone, Categories, addr_book, attendee, email122 except:123 log('Unable to read the user data or data file missing','error')...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!