Best Python code snippet using fMBT_python
fmbtx11.py
Source:fmbtx11.py
...130 def _dumpItem(self, viewItem):131 return "id=%s cls=%s text=%s bbox=%s" % (132 viewItem._itemId, repr(viewItem._className), repr(viewItem._text),133 viewItem._bbox)134 def _dumpTree(self, rootItem, depth=0):135 l = ["%s%s" % (" " * (depth * 4), self._dumpItem(rootItem))]136 for child in rootItem.children():137 l.extend(self._dumpTree(child, depth+1))138 return l139 def dumpTree(self, rootItem=None):140 """141 Returns item tree as a string142 """143 if rootItem == None:144 rootItem = self.rootItem()145 return "\n".join(self._dumpTree(rootItem))146 def __str__(self):147 return "View(%s, %s items)" % (repr(self._dumpFilename), len(self._viewItems))148 def findItems(self, comparator, count=-1, searchRootItem=None, searchItems=None, onScreen=False):149 foundItems = []150 if count == 0: return foundItems151 if searchRootItem != None:152 if comparator(searchRootItem) and (153 not onScreen or (self._itemOnScreen(searchRootItem))):154 foundItems.append(searchRootItem)155 for c in searchRootItem.children():156 foundItems.extend(self.findItems(comparator, count=count-len(foundItems), searchRootItem=c, onScreen=onScreen))157 else:158 if searchItems:159 domain = iter(searchItems)...
utils.py
Source:utils.py
1import collections2import numbers3import sys4import os5def _dumpTree( indent, obj, depth, excludeList):6 if obj is None:7 return "None"8 elif isinstance(obj, numbers.Number):9 if isinstance(obj, numbers.Integral):10 return "%d" % int(obj)11 elif isinstance(obj, numbers.Real) and obj.is_integer():12 return "%d" % int(obj)13 else:14 return "%.5f" % obj15 elif isinstance(obj, str):16 return '"' + obj + '"'17 elif isinstance(obj, bytes):18 return '"' + obj.decode('utf-8') + '"'19 elif isinstance(obj, collections.Sequence):20 if (depth == 0):21 return "{...}"22 s = ''23 i = 024 for v in obj:25 ke = "\n" + indent + "number " + str(i+1)26 ve = _dumpTree( indent + ' ', v, depth-1, excludeList)27 if ve and ve[0] == "\n":28 s = s + ke + ":" + ve29 else:30 s = s + ke + ": " + ve31 i = i + 132 return s33 elif isinstance(obj, dict):34 if (depth == 0):35 return "{...}"36 s = ''37 for k in sorted( obj.keys()):38 kstr = str(k)39 if kstr[0] == '_':40 continue41 if kstr in excludeList:42 continue43 ke = "\n" + indent + type(k).__name__ + " " + kstr44 ve = _dumpTree( indent + ' ', obj[ k], depth-1, excludeList)45 if ve and ve[0] == "\n":46 s = s + ke + ":" + ve47 else:48 s = s + ke + ": " + ve49 return s50 else:51 attrdict = {}52 for k in dir(obj):53 if k[0] != '_' and getattr( obj, k) != None:54 attrdict[ k] = getattr( obj, k)55 return _dumpTree( indent, attrdict, depth, excludeList)56def dumpTree( obj):...
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!!