Best Python code snippet using fMBT_python
eyenfinger.py
Source:eyenfinger.py  
...557    score, text, bbox = score_text_box_list[0]558    if capture:559        drawBbox(_g_origImage, capture, bbox, "%.2f %s" % (score, text))560    return ((score, matching_text), bbox)561def iVerifyIcon(iconFilename, match=None, colorMatch=None, opacityLimit=None, capture=None, area=(0.0, 0.0, 1.0, 1.0), _origin="iVerifyIcon"):562    """563    DEPRECATED - use fmbtx11.Screen.verifyBitmap instead.564    Verify that icon can be found from previously iRead() image.565    Parameters:566        iconFilename   name of the icon file to be searched for567        match          minimum matching score between 0 and 1.0,568                       1.0 is perfect match (default)569        colorMatch     1.0 (default) requires exact color match. Value570                       below 1.0 defines maximum allowed color571                       difference. See iSetDefaultIconColorMatch.572        opacityLimit   0.0 (default) requires exact color values573                       independently of opacity. If lower than 1.0,574                       pixel less opaque than given value are skipped575                       in pixel perfect comparisons.576        capture        save image with verified icon highlighted577                       to this file. Default: None (nothing is saved).578        area           rectangle (left, top, right, bottom). Search579                       icon inside this rectangle only. Values can be580                       absolute coordinates, or floats in range [0.0,581                       1.0] that will be scaled to image dimensions.582                       The default is (0.0, 0.0, 1.0, 1.0), that is583                       full rectangle.584    Returns pair: (score, (left, top, right, bottom)), where585        score          score of found match (1.0 for perfect match)586        (left, top, right, bottom)587                       bounding box of found icon588    Throws BadMatch error if icon is not found.589    """590    if not eye4graphics:591        _log('ERROR: %s("%s") called, but eye4graphics not loaded.' % (_origin, iconFilename))592        raise EyenfingerError("eye4graphics not available")593    if not _g_origImage:594        _log('ERROR %s("%s") called, but source not defined (iRead not called).' % (_origin, iconFilename))595        raise BadSourceImage("Source image not defined, cannot search for an icon.")596    if not (os.path.isfile(iconFilename) and os.access(iconFilename, os.R_OK)):597        _log('ERROR %s("%s") called, but the icon file is not readable.' % (_origin, iconFilename))598        raise BadIconImage('Icon "%s" is not readable.' % (iconFilename,))599    if match == None:600        match = _g_defaultIconMatch601    if match > 1.0:602        _log('ERROR %s("%s"): invalid match value, must be below 1.0. ' % (_origin, iconFilename,))603        raise ValueError("invalid match value: %s, should be 0 <= match <= 1.0" % (match,))604    if colorMatch == None:605        colorMatch = _g_defaultIconColorMatch606    if not 0.0 <= colorMatch <= 1.0:607        _log('ERROR %s("%s"): invalid colorMatch value, must be between 0 and 1. ' % (_origin, iconFilename,))608        raise ValueError("invalid colorMatch value: %s, should be 0 <= colorMatch <= 1.0" % (colorMatch,))609    if opacityLimit == None:610        opacityLimit = _g_defaultIconOpacityLimit611    if not 0.0 <= opacityLimit <= 1.0:612        _log('ERROR %s("%s"): invalid opacityLimit value, must be between 0 and 1. ' % (_origin, iconFilename,))613        raise ValueError("invalid opacityLimit value: %s, should be 0 <= opacityLimit <= 1.0" % (opacityLimit,))614    if area[0] > area[2] or area[1] >= area[3]:615        raise ValueError("invalid area: %s, should be rectangle (left, top, right, bottom)" % (area,))616    leftTopRightBottomZero = (_coordsToInt((area[0], area[1]), windowSize()) +617                               _coordsToInt((area[2], area[3]), windowSize()) +618                               (0,))619    struct_area_bbox = Bbox(*leftTopRightBottomZero)620    struct_bbox = Bbox(0,0,0,0,0)621    threshold = int((1.0-match)*20)622    err = eye4graphics.findSingleIcon(ctypes.byref(struct_bbox),623                                      _g_origImage, iconFilename, threshold,624                                      ctypes.c_double(colorMatch),625                                      ctypes.c_double(opacityLimit),626                                      ctypes.byref(struct_area_bbox))627    bbox = (int(struct_bbox.left), int(struct_bbox.top),628            int(struct_bbox.right), int(struct_bbox.bottom))629    if err == -1 or err == -2:630        msg = '%s: "%s" not found, match=%.2f, threshold=%s, closest threshold %s.' % (631            _origin, iconFilename, match, threshold, int(struct_bbox.error))632        if capture:633            drawIcon(_g_origImage, capture, iconFilename, bbox, 'red')634        _log(msg)635        raise BadMatch(msg)636    elif err != 0:637        _log("%s: findSingleIcon returned %s" % (_origin, err,))638        raise BadMatch("%s not found, findSingleIcon returned %s." % (iconFilename, err))639    if threshold > 0:640        score = (threshold - int(struct_bbox.error)) / float(threshold)641    else:642        score = 1.0643    if capture:644        drawIcon(_g_origImage, capture, iconFilename, bbox, area=leftTopRightBottomZero[:4])645    return (score, bbox)646def iClickIcon(iconFilename, clickPos=(0.5,0.5), match=None,647               colorMatch=None, opacityLimit=None,648               mouseButton=1, mouseEvent=MOUSEEVENT_CLICK, dryRun=None, capture=None):649    """650    DEPRECATED - use fmbtx11.Screen.tapBitmap instead.651    Click coordinates relative to the given icon in previously iRead() image.652    Parameters:653        iconFilename read icon from this file654        clickPos     position to be clicked,655                     relative to word top-left corner of the bounding656                     box around the word. X and Y units are relative657                     to width and height of the box.  (0,0) is the658                     top-left corner, (1,1) is bottom-right corner,659                     (0.5, 0.5) is the middle point (default).660                     Values below 0 or greater than 1 click outside661                     the bounding box.662        match        1.0 (default) requires exact match. Value below 1.0663                     defines minimum required score for fuzzy matching664                     (EXPERIMENTAL). See iSetDefaultIconMatch.665        colorMatch   1.0 (default) requires exact color match. Value666                     below 1.0 defines maximum allowed color667                     difference. See iSetDefaultIconColorMatch.668        opacityLimit 0.0 (default) requires exact color values669                     independently of opacity. If lower than 1.0,670                     pixel less opaque than given value are skipped671                     in pixel perfect comparisons.672        mouseButton  mouse button to be synthesized on the event, default is 1.673        mouseEvent   event to be synthesized, the default is MOUSEEVENT_CLICK,674                     others: MOUSEEVENT_MOVE, MOUSEEVENT_DOWN, MOUSEEVENT_UP.675        dryRun       if True, does not synthesize events. Still returns676                     coordinates of the clicked position and illustrates677                     the clicked position on the capture image if678                     given.679        capture      name of file where image of highlighted icon and680                     clicked point are saved.681    Returns pair (score, (clickedX, clickedY)), where682        score        score of found match (1.0 for perfect match)683        (clickedX, clickedY)684                     X and Y coordinates of clicked position on the685                     screen.686    Throws BadMatch error if could not find a matching word.687    """688    _DEPRECATED()689    score, bbox = iVerifyIcon(iconFilename, match=match,690                              colorMatch=colorMatch, opacityLimit=opacityLimit,691                              capture=capture, _origin="iClickIcon")692    clickedXY = iClickBox(bbox, clickPos, mouseButton, mouseEvent, dryRun,693                          capture, _captureText = iconFilename)694    return (score, clickedXY)695def iClickWord(word, appearance=1, clickPos=(0.5,0.5), match=0.33,696               mouseButton=1, mouseEvent=1, dryRun=None, capture=None):697    """698    DEPRECATED - use fmbtx11.Screen.tapOcrText instead.699    Click coordinates relative to the given word in previously iRead() image.700    Parameters:701        word         word that should be clicked702        appearance   if word appears many times, appearance to703                     be clicked. Defaults to the first one....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!!
