← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #209147]: if exists with try catch

 

Question #209147 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/209147

    Status: Answered => Open

Omkkumar is still having a problem:
Hi raiman ,

The above solution works perfectly fine when it is run in sikuli  IDE .
But when i give the path of the image and try to to run the script in
eclipse IDE the if exists condition is not working . here is my code and
folder structure

My project resides in the directory :
C:\workspace\Sikuli_Project\src
Following are the commomSikuli files  which i am maintaing under the src directory
C:\workspace\Sikuli_Project\src\Images.sikuli #whr my images for all the test cases exists
C:\workspace\Sikuli_Project\src\utility.py
C:\workspace\Sikuli_Project\src\verificationpoint.sikuli\verification.py
C:\workspace\Sikuli_Project\src\TestSuite.py
TestSuite .py is a suite like thing which run my .py test cases file one by one by execfile 

My actual test case lies in the folder structure
C:\workspace\Sikuli_Project\src\TestCase\TestCase.py
and this TestCase.py will inturn call another sikuli in the same directory . 
C:\workspace\Sikuli_Project\src\TestCase\TestCase1.sikuli\TestCase1.py

Here is my code for TestCase.py
class TestCase.py():
       def execute(self):
               try:
                    if not running in a suite :
                          utility.createheaderreport()#Method under the utility class to create a folder and log report 
                          os.chdir("C:\workspace\Sikuli_Project\src")#Since the previous command will create a folder in someother location i am instructing it to come back to project directory and run it 
                          utility.startApp()#method to start the application
                          execfile(".\verificationpoint.sikuli\verificationpoint.py")#please see the contents which i have written inside this verificationpoint.py below
                          self.callanotherfunction()
                      else if running in suite :
                             #will execute the same steps as above except for some mods              
                 except:
                          print "exception handled
         def callanotherfunction():
                          execfile(".\TestCase\TestCase1.sikuli\TestCase1.py")


                       
Script inside C:\workspace\Sikuli_Project\src\verificationpoint.sikuli\verification.py

addImagePath("C:\\workspace\\Sikuli_Project\\src\\Images.sikuli\\

if exists(Pattern("file.png'").similar(0.95)):
    getLastMatch().highlight(3)
    click(getLastMatch())

The if exists condition fails even if the image exists...:-(

rather if i just give 
try:
  click ("file.png'')
except:
   exit(1)
it is working 
I am sorry if the question is sillyyy.
This is breaking my head raiman..
Please suggest me a solution

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.