← Back to team overview

sikuli-driver team mailing list archive

[Bug 1381945] [NEW] The With keyword is not reliable

 

Public bug reported:

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)

** Affects: sikuli
     Importance: Undecided
         Status: New


** Tags: region wait while with

** Description changed:

+ 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    
+     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)
+     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)
+     try:
+         rDispSchemeList.click(pImage)
+         type(Key.ENTER)
+         break
+     except FindFailed:
+         type(Key.DOWN)

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1381945

Title:
  The With keyword is not reliable

Status in Sikuli:
  New

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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1381945/+subscriptions


Follow ups

References