How to use settextvalue method in pyatom

Best Python code snippet using pyatom_python

contact.py

Source:contact.py Github

copy

Full Screen

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 evoutils.mail import *28from evoutils import *29def deletecontact(name, contactlist=False):30 try:31 if contactlist == False:32 selectcontact (titleappend(name)[1:])33 else:34 selectcontact (name)35 selectmenuitem ('frmEvolution-Contacts','mnuEdit;mnuDeleteContact')36 waittillguiexist ('dlgQuestion')37 click ('dlgQuestion','btnDelete')38 waittillguinotexist ('dlgQuestion')39 try:40 if contactlist == False:41 selectcontact (titleappend(name)[1:])42 else:43 selectcontact (name)44 except:45 return46 raise LdtpExecutionError(0)47 except:48 log ('Deleting Contact Failed','error')49 raise LdtpExecutionError(0)50 51def getcontactvals(datafilename):52 """ GET INFORMATION FROM XML FILE FOR ADDING CONTACTS"""53 try:54 data_object = LdtpDataFileParser (datafilename)55 AddrBook=data_object.gettagvalue ('AddrBook')56 FullName=data_object.gettagvalue ('FullName')57 Nick=data_object.gettagvalue ('NickName')58 WorkEmail=data_object.gettagvalue ('WorkEmail')59 HomeMail=data_object.gettagvalue ('HomeEmail')60 BusPhone=data_object.gettagvalue ('BusinessPhone')61 Yahoo=data_object.gettagvalue ('Yahoo')62 HomePage=data_object.gettagvalue ('HomePage')63 Profession=data_object.gettagvalue ('Profession')64 Notes=data_object.gettagvalue ('Notes')65 HomeAdd=data_object.gettagvalue ('HomeAddress')66 WorkAdd=data_object.gettagvalue ('WorkAddress')67 OtherAdd=data_object.gettagvalue ('OtherAddress')68 except:69 log ('Error While reading values from XML file','error')70 log ('Add New Contact','testend')71 raise LdtpExecutionError(0)72 return AddrBook,FullName,Nick,WorkEmail,HomeMail,BusPhone,Yahoo,HomePage,Profession,Notes,HomeAdd,WorkAdd,OtherAdd73def selectPanel(components='Mail'):74 """Selects Pane in Evolution"""75 try:76 window_id = 'frmEvolution-*'77 click (window_id, 'tbtn' + components)78 if components != 'Mail':79 waittillguiexist ('frmEvolution-' + components)80 except:81 log ('error selecting pane','error')82 raise LdtpExecutionError(0)83def selectaddrbook (name):84 try:85 selectContactPane()86 if name:87 selectrow ('frmEvolution-Contacts','ttblContactSourceSelector',name)88 except:89 log ('Unable to Select AddressBook','error')90 raise LdtpExecutionError (0)91def selectcontact(name):92 if guiexist ('frmEvolution-Contacts')!=1:93 selectContactPane() 94 try:95 remap ('evolution','frmEvolution-Contacts')96 for obj in getobjectlist ('frmEvolution-Contacts'):97 if obj.startswith ('pnlcurrentaddressbook'):98 panel_name=obj99 break100 time.sleep (2)101 selectpanelname ('frmEvolution-Contacts',panel_name,name)102 time.sleep (2)103 except:104 log ('Select Contact Failed','error')105 raise LdtpExecutionError(0)106 107def titleappend(name):108 name=name.split (' ')109 append=''110 for x in range(1,len(name)):111 append=' '+name[x]112 if len(name)>1:113 append+=', '114 append+=name[0]115 else:116 append+=' '117 append+=name[0]118 return append119 120def getmodifiedvals(datafilename):121 """Get Data from an XML file for Contact Modification"""122 data_object = LdtpDataFileParser (datafilename)123 AddrBook=data_object.gettagvalue ('AddrBook')124 FullName==data_object.gettagvalue ('Name')125 NewWorkEmail=data_object.gettagvalue ('NewWorkEmail')126 NewHomeEmail=data_object.gettagvalue ('NewHomeEmail')127 NewHomeAdd=data_object.gettagvalue ('NewHomeAddress')128 NewWordAdd=data_object.gettagvalue ('NewWorkAddress')129 NewOtherAdd=data_object.gettagvalue ('NewOtherAddress')130 return AddrBook,FullName,NewWorkEmail,NewHomeEmail,NewHomeAdd,NewWorkAdd,NewOtherAdd131def getcontactlistvals(datafilename):132 data_object = LdtpDataFileParser (datafilename)133 ListName=data_object.gettagvalue ('ListName')134 EmailAddresses=[]135 try:136 indexval=1137 while True:138 try:139 mail=data_object.gettagvalue ('Email'+str(indexval))[0]140 EmailAddresses.append(mail)141 if mail=='':142 break143 except:144 break145 indexval=indexval+1146 except:147 log ('error while getting contact list values','error')148 raise LdtpExecutionError(0)149 return ListName,EmailAddresses150def getmodlistvals(datafilename):151 data_object = LdtpDataFileParser (datafilename)152 ListName=data_object.gettagvalue ('ListName')153 AddEmailAddresses=[]154 DelEmailAddresses=[]155 addmail=''156 delmail=''157 try:158 indexval=1159 while True:160 try:161 addmail=data_object.gettagvalue ('AddEmail'+str(indexval))162 delmail=data_object.gettagvalue ('DelEmail'+str(indexval))163 if len(addmail) ==0 and len (delmail)==0:164 break 165 if len (addmail)>0:166 AddEmailAddresses.append (addmail[0])167 if len(delmail)>0:168 DelEmailAddresses.append (delmail[0])169 except:170 log ('Error in Data read','error')171 break172 indexval=indexval+1173 print AddEmailAddresses,DelEmailAddresses174 time.sleep (5)175 except:176 log ('error while getting contact list values','error')177 raise LdtpExecutionError(0)178 return ListName,AddEmailAddresses,DelEmailAddresses179 180def opencontactlist(ListName):181 try:182 selectcontact (ListName[0])183 selectmenuitem ('frmEvolution-Contacts','mnuFile;mnuOpen')184 waittillguiexist ('*'+ListName[0]+'*')185 except:186 log ('could not open Contact list','error')187 raise LdtpExecutionError(0)188def deletecontactlist(name):189 try:190 deletecontact(name)191 except:192 log ('Delete Contact List Failed','error')193 raise LdtpExecutionError(0)194def opennewcontact (AddrBook=[]):195 #OPEN CONTACT EDITOR196 try:197 selectContactPane()198 if AddrBook:199 selectaddrbook (AddrBook[0])200 selectmenuitem ('frmEvolution-Contacts','mnuFile;mnuNew;mnuContact')201 time.sleep(2)202 waittillguiexist ('*ContactEditor*')203 except:204 log ('Could Not select Contacts Button','error')205 raise LdtpExecutionError(0)206def addcontact(AddrBook,FullName,Nick,WorkEmail,HomeMail,BusPhone,Yahoo,HomePage,Profession,Notes,HomeAdd,WorkAdd,OtherAdd):207 """ Adds a new contact to evolution"""208 #SET VALUES FOR CONTACT TAB209 try:210 selecttab ('*ContactEditor*','ptl0','Contact')211 settextvalue ('*ContactEditor*','txtFullName', FullName[0])212 if len(Nick)>0:213 settextvalue ('*ContactEditor*','txtNickname',Nick[0])214 if len(WorkEmail)>0:215 settextvalue ('*ContactEditor*','txtWork',WorkEmail[0])216 if len(HomeMail)>0:217 settextvalue ('*ContactEditor*','txtHome',HomeMail[0])218 if len(BusPhone)>0:219 settextvalue ('*ContactEditor*','txtBusinessPhone',BusPhone[0])220 #print "YAHOO[0]",Yahoo[0]221 if len(Yahoo)>0:222 print "INSIDE"223 settextvalue ('*ContactEditor*','txtYahoo',Yahoo[0])224 except:225 log ('Error While setting values in 1st tab','error')226 raise LdtpExecutionError(0)227 time.sleep(2)228 #PERSONAL INFORMATION TAB229 try:230 if len(HomePage)>0 or len(Profession)>0 or len(Notes)>0:231 selecttab ('*ContactEditor*','ptl0','Personal Information')232 time.sleep(1)233 if len(HomePage)>0:234 settextvalue ('*ContactEditor*','txtHomePage',HomePage[0])235 if len(Profession)>0:236 settextvalue ('*ContactEditor*','txtProfession',Profession[0])237 if len(Notes)>0:238 settextvalue ('*ContactEditor*','txtNotes',Notes[0])239 except:240 log ('Error While setting values in 2nd tab','error')241 raise LdtpExecutionError(0)242 time.sleep(2)243 #MAILING ADDRESS TAB244 try:245 if len(HomeAdd)>0 or len(WorkAdd)>0 or len(OtherAdd)>0:246 selecttab ('*ContactEditor*','ptl0','Mailing Address')247 time.sleep(1)248 if len(HomeAdd)>0:249 settextvalue ('*ContactEditor*','txtAddress',HomeAdd[0])250 if len(WorkAdd)>0:251 settextvalue ('*ContactEditor*','txtAddress1',WorkAdd[0])252 if len(OtherAdd)>0:253 settextvalue ('*ContactEditor*','txtAddress2',OtherAdd[0])254 except:255 log ('Error While setting values in 3rd tab','error')256 raise LdtpExecutionError(0)257 time.sleep (2)258 try:259 click ('*ContactEditor*','btnOK')260 time.sleep (5)261 if guiexist ('dlgDuplicateContactDetected')==1:262 log ('contact already exists','info')263 click ('dlgDuplicateContactDetected','btnAdd')264 time.sleep(2)265 verifyaddedcontact(AddrBook,FullName,Nick,WorkEmail,HomeMail,BusPhone,Yahoo,HomePage,Profession,Notes,HomeAdd,WorkAdd,OtherAdd)266 time.sleep(2)267 except:268 log ('Contact Addition Failed!','error')269 raise LdtpExecutionError(0)270def verifyaddedcontact(AddrBook,FullName,Nick,WorkEmail,HomeMail,BusPhone,Yahoo,HomePage,Profession,Notes,HomeAdd,WorkAdd,OtherAdd):271 try:272 selectaddrbook (AddrBook[0])273 temp=titleappend(FullName[0])[1:]274 selectcontact(temp)275 time.sleep (2)276 selectmenuitem ('frmEvolution-Contacts','mnuFile;mnuOpen')277 title='*ContactEditor*-'+titleappend(FullName[0]).replace(' ','')278 waittillguiexist ('*ContactEditor*')279 time.sleep(2)280 if gettextvalue ('*ContactEditor*','txtFullName')!=FullName[0]:281 log ('Full Name does not match','info')282 raise LdtpExecutionError(0)283 if len(Nick)>0 and gettextvalue ('*ContactEditor*','txtNickname')!=Nick[0]:284 log ('Nick Name matches','info')285 raise LdtpExecutionError(0)286 if len (WorkEmail)>0 and gettextvalue ('*ContactEditor*','txtWork')!=WorkEmail[0]:287 log ('Work Email matches','info')288 raise LdtpExecutionError(0)289 if len(HomeMail)>0 and gettextvalue ('*ContactEditor*','txtHome')!=HomeMail[0]:290 log ('Home Email matches','info')291 raise LdtpExecutionError(0)292 if len(BusPhone)>0 and gettextvalue ('*ContactEditor*','txtBusinessPhone')!=BusPhone[0]:293 log ('Business Phone matches','info')294 raise LdtpExecutionError(0)295 print "Bus phone over"296 if len (Yahoo)>0 and gettextvalue ('*ContactEditor*','txtYahoo')!=Yahoo[0]:297 log ('Yahoo ID matches','info')298 raise LdtpExecutionError(0)299 if len(HomePage)>0 and gettextvalue ('*ContactEditor*','txtHomePage')!=HomePage[0]:300 log ('Home Page matches','info')301 raise LdtpExecutionError(0)302 if len( Profession)>0 and gettextvalue ('*ContactEditor*','txtProfession')!=Profession[0]:303 log ('Profession matches','info')304 raise LdtpExecutionError(0)305 if len(Notes)>0 and gettextvalue ('*ContactEditor*','txtNotes')!=Notes[0]:306 log ('Notes matches','info')307 raise LdtpExecutionError(0)308 homeaddress=gettextvalue ('*ContactEditor*','txtAddress')309 if len(HomeAdd)>0 and gettextvalue ('*ContactEditor*','txtAddress')!=HomeAdd[0]:310 #print "Error here","from dialog:"+homeaddress+"a","from xml file:"+HomeAdd[0]311 log ('Home Address matches','info')312 raise LdtpExecutionError(0)313 if len (WorkAdd)>0 and gettextvalue ('*ContactEditor*','txtAddress1')!=WorkAdd[0]:314 log ('Work Address matches','info')315 raise LdtpExecutionError(0)316 if len(OtherAdd)>0 and gettextvalue ('*ContactEditor*','txtAddress2')!=OtherAdd[0]:317 log ('Other Address matches','info')318 raise LdtpExecutionError(0)319 click ('*ContactEditor*','btnCancel')320 except:321 log ('Contact has not been added correctly','error')...

Full Screen

Full Screen

task.py

Source:task.py Github

copy

Full Screen

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')...

Full Screen

Full Screen

showmoreoptions.py

Source:showmoreoptions.py Github

copy

Full Screen

1settextvalue('SearchforFiles','txtNameContainsEntry','abcd.py')2click('SearchforFiles','tbtnShowmoreoptions')3#settextvalue('SearchforFiles'4click('SearchforFiles','btnAdd')5settextvalue('SearchforFiles','txtSearchRuleValueEntry','aaa')6click('SearchforFiles','btnFind')7click('SearchforFiles','btnRemove')...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful