Best Python code snippet using fMBT_python
fmbtx11.py
Source:fmbtx11.py  
...261            window = self._refreshViewDefaults.get("window", None)262        if viewSource == None:263            viewSource = self._refreshViewDefaults.get("viewSource", "atspi")264        if viewSource == "atspi":265            foundItems = self.existingConnection().recvAtspiViewData(window)266            if self.screenshotDir() == None:267                self.setScreenshotDir(self._screenshotDirDefault)268            if self.screenshotSubdir() == None:269                self.setScreenshotSubdir(self._screenshotSubdirDefault)270            viewFilename = self._newScreenshotFilepath()[:-3] + "view"271            file(viewFilename, "w").write(repr(foundItems))272            self._lastView = View(273                viewFilename, foundItems,274                itemOnScreen=lambda i: self.itemOnScreen(i))275        else:276            raise ValueError('viewSource "%s" not supported' % (viewSource,))277        return self._lastView278    def refreshViewDefaults(self):279        return self._refreshViewDefaults280    def setRefreshViewDefaults(self, **kwargs):281        """Set default arguments for refreshView() calls282        Parameters:283          **kwargs (keyword arguments)284                  new default values for optional refreshView() parameters.285        """286        self._refreshViewDefaults = kwargs287    def tapText(self, text, partial=False, **tapKwArgs):288        """289        Find an item with given text from the latest view, and tap it.290        Parameters:291          partial (boolean, optional):292                  refer to verifyText documentation. The default is293                  False.294          tapPos (pair of floats (x, y)):295                  refer to tapItem documentation.296          button, long, hold, count, delayBetweenTaps (optional):297                  refer to tap documentation.298        Returns True if successful, otherwise False.299        """300        items = self.existingView().findItemsByText(text, partial=partial, count=1, onScreen=True)301        if len(items) == 0: return False302        return self.tapItem(items[0], **tapKwArgs)303    def verifyText(self, text, partial=False):304        """305        Verify that the last view has at least one item with given306        text.307        Parameters:308          text (string):309                  text to be searched for in items.310          partial (boolean, optional):311                  if True, match items if item text contains given312                  text, otherwise match only if item text is equal to313                  the given text. The default is False (exact match).314        """315        assert self._lastView != None, "View required."316        return self._lastView.findItemsByText(text, partial=partial, count=1, onScreen=True) != []317    def view(self):318        return self._lastView319    def windowList(self):320        """321        Return list of properties of windows (dictionaries)322        Example: list window id's and names:323          for props in screen.windowList():324              print props["window"], props["name"]325        """326        return self.existingConnection().recvChildWindows(recursive=True)327class X11Connection(fmbtx11_conn.Display):328    def __init__(self, display):329        fmbtx11_conn.Display.__init__(self, display)330    def target(self):331        return "X11"332    def recvAtspiViewData(self, window):333        return fmbtx11_conn.atspiViewData(window)334    def recvScreenshot(self, filename):335        # This is a hack to get this stack quickly testable,336        # let's replace this with Xlib/libMagick functions, too...337        data = fmbtx11_conn.Display.recvScreenshot(self, "PNG")338        if data:339            if data.startswith("FMBTRAWX11"):340                try:341                    header, zdata = data.split('\n', 1)342                    width, height, depth, bpp = [int(n) for n in header.split()[1:]]343                    data = zlib.decompress(zdata)344                except Exception, e:345                    raise FMBTX11Error("Corrupted screenshot data: %s" % (e,))346                if len(data) != width * height * 4:...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!!
