Best Python code snippet using pyatom_python
ldtpd.py
Source:ldtpd.py  
...133      for j in range(0,numcols):134        try:135          value = ldtp.getcellvalue(window, table, i, j)136          if self._matches(target,value):137            ldtp.selectrowindex(window, table, i)138            return i139        except:140          continue141    raise Exception("Item not found in table!")142  #this only searches the first column and is much quicker.143  def _quickgettablerowindex(self, window, table, target):144    numrows = ldtp.getrowcount(window, table)145    for i in range(0,numrows):146      try:147        value = ldtp.getcellvalue(window, table, i, 0)148        if self._matches(target,value):149          ldtp.selectrowindex(window, table, i)150          return i151      except:152        continue153    raise Exception("Item not found in table!")154  def _window_search(self,match,term):155    if re.search(fnmatch.translate(term),156                   match,157                   re.U | re.M | re.L) \158          or re.search(fnmatch.translate(re.sub("(^frm|^dlg)", "", term)),159                       re.sub(" *(\t*)|(\n*)", "", match),160                       re.U | re.M | re.L):161      return True162    else:163      return False...table.py
Source:table.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    open_evo ()32except:33    raise34data_object     = LdtpDataFileParser (datafilename)35rows            = data_object.gettagvalue ('rowcount')36evo_win  = '*Evolution*'37pref     = '*EvolutionPreferences'38acnt_tab = 'tblMailAccounts'39log ('getrowcount','teststart')40try:41    selectmenuitem (evo_win, 'mnuEdit;mnuPreferences')42    if waittillguiexist (pref) == 0:43        log ('Preferences Window not open yet','cause')44        raise LdtpExecutionError (str (traceback.format_exc ()))45    row_count = getrowcount (pref, acnt_tab)46    if rows != [] and rows != row_count:47        log ('No of rows does not match with input','cause')48        raise LdtpExecutionError (str (traceback.format_exc ()))49except:50    testfail ('getrowcount')51    raise LdtpExecutionError (str (traceback.format_exc ()))52testpass ('getrowcount')53acnts = []54log ('getcellvalue', 'teststart')55try:56    for index in range (row_count):57        val = getcellvalue (pref, acnt_tab, index, 1)58## http://bugzilla.gnome.org/show_bug.cgi?id=35222059#         if verifytablecell (pref, acnt_tab, index, 1, val) == 0:60#             log ('problem in getcellvalue','cause')61#             raise LdtpExecutionError (str (traceback.format_exc ()))62        acnts.append (val)63except:64    testfail ('getcellvalue')65    raise LdtpExecutionError (str (traceback.format_exc ()))66testpass ('getcellvalue')67log ('selectrowindex','teststart')68try:69    for index in range (row_count):70        if selectrowindex (pref, acnt_tab, index) != 1:71            log ('Unable to select index','cause')72            raise LdtpExecutionError (str (traceback.format_exc ()))73        #time.sleep (1)74        if gettablerowindex (pref, acnt_tab, acnts[index]) != index:75            log ('Index not selected','cause')76            raise LdtpExecutionError (str (traceback.format_exc ()))77except:78    testfail ('selectrowindex')79    raise LdtpExecutionError (str (traceback.format_exc ()))80testpass ('selectrowindex')81log ('selectrow','teststart')82try:83    index = 084    for acnt in acnts:85        if doesrowexist (pref, acnt_tab, acnt) == 1 and selectrow (pref, acnt_tab, acnt) != 1:86            log ('Unable to select row','cause')87            raise LdtpExecutionError (str (traceback.format_exc ()))88        #time.sleep (1)89        if gettablerowindex (pref, acnt_tab, acnt) != index:90            log ('Index not selected','cause')91            raise LdtpExecutionError (str (traceback.format_exc ()))92        index += 193except:94    testfail ('selectrow')95    raise LdtpExecutionError (str (traceback.format_exc ()))96testpass ('selectrow')97log ('selectlastrow','teststart')98try:99    if selectlastrow (pref,acnt_tab) != 1:100        log ('selectlastrow failed','cause')101        raise LdtpExecutionError (str (traceback.format_exc ()))102    #time.sleep (1)103    if gettablerowindex (pref, acnt_tab, acnt) != (len (acnts)-1):104        log ('Index not selected','cause')105        raise LdtpExecutionError (str (traceback.format_exc ()))106except:107    testfail ('selectlastrow')108    raise LdtpExecutionError (str (traceback.format_exc ()))109testpass ('selectlastrow')110log ('checkrow','teststart')111try:112    for index in range (row_count):113        if uncheckrow (pref, acnt_tab, index) == 0:114            log ('Unable to uncheck row','cause')115            raise LdtpExecutionError (str (traceback.format_exc ()))116        #time.sleep (2)117        if checkrow (pref, acnt_tab, index) == 0:118            log ('Unable to check row','cause')119            raise LdtpExecutionError (str (traceback.format_exc ()))120except:121    testfail ('checkrow')122    raise LdtpExecutionError (str (traceback.format_exc ()))123testpass ('checkrow')...gnome-font.py
Source:gnome-font.py  
...13  appmap_path = sys.argv[1]14initappmap (appmap_path + '/gnome-font-properties.map')15launchapp ('gnome-font-properties')16click('dlgFontPreferences','btnApplicationfont')17selectrowindex('dlgPickaFont','tblFamily',5)18selectrowindex('dlgPickaFont','tblStyle',3)19selectrowindex('dlgPickaFont','tblSize',5)...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!!
