[1.0.1] Jython With: setAutoWaitTimeout ignored - fixed in 1.1.0

Bug #1381945 reported by Ned
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Fix Committed
Critical
RaiMan

Bug Description

Version 1.0.1

I have found that when using the with keyword with a region, it does not always apply to the statements beneath.

For example, in the following code

def dispSchemeListRegion(sTestId,iDelay):
    match = findLog(sTestId,pDispScreenTitleBar)

    if(match):
        x = match.getX()
        y = match.getY()
    else:
        exit(0)
    reg = Region(x,y,483,217)
    rDispSchemeList = Region(reg.offset(463,429))

    rDispSchemeList.setAutoWaitTimeout(iDelay)
    return rDispSchemeList

-----------------------------------------------------------------------------
rDispSchemeList = dispSchemeListRegion(sTestId,0.5)

#the wait delay of .5 seconds is not applied to the the while loop

with rDispSchemeList:
    while not exists(pDispSchemeScrollBarBottom):
         try:
             rDispSchemeList.click(pImage)
             type(Key.ENTER)
             break
         except FindFailed:
                type(Key.DOWN)

#however, in the following example, it is and the whole block runs much faster

while not rDispSchemeList.exists(pDispSchemeScrollBarBottom):
    try:
        rDispSchemeList.click(pImage)
        type(Key.ENTER)
        break
    except FindFailed:
        type(Key.DOWN)

Ned (nedleonard)
description: updated
RaiMan (raimund-hocke)
Changed in sikuli:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.2.0
RaiMan (raimund-hocke)
summary: - The With keyword is not reliable
+ [1.0.1] Jython With: setAutoWaitTimeout ignored - fixed in 1.1.0
Changed in sikuli:
status: In Progress → Fix Committed
importance: Medium → Critical
milestone: 1.2.0 → 1.1.0
Revision history for this message
RaiMan (raimund-hocke) wrote :

confirmed: bug in 1.0.1

fixed in 1.1.0:

--- testscript:
reg = Region(0,0,100,100)
reg.setAutoWaitTimeout(1)
print "reg.TO:", reg.getAutoWaitTimeout()

with reg:
  print "TO:", getAutoWaitTimeout()
  start = time.time()
  i = 0
  while not exists(Pattern("some_not_visible.png").exact()):
    print time.time() - start
    start = time.time()
    i += 1
    if i > 1: break

--- prints
reg.TO: 0.5
TO: 0.5
0.667000055313
0.669000148773

--- BTW:
I do not really see an advantage using "with" for just saving some repeated usage of some_region. and having an additional indent level.

In my opinion the explicit usage of the dotted version with the prefixed region makes things much clearer and you then know throughout the script, that an undotted usage like click() addresses the screen.

--- One more thing:
In 1.1.0 there is an alternative for with:

use(some_region)
click() # is processed against some_region

use()
click() # now again uses SCREEN

I added this to support switching between screens in a multi monitor environment including remote screens.
But it can as well be used with a region and saves the additional indent.

Revision history for this message
Ned (nedleonard) wrote :

Thanks for replying, sorry for reposting

Revision history for this message
RaiMan (raimund-hocke) wrote :

what reposting? You did not do anything wrong.

I only changed the header, to be more specific and show it is solved in 1.1.0

Revision history for this message
Ned (nedleonard) wrote :

Oh okay then :) Thanks for the response though, the use() feature sounds really nice

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.