openApp failed file not found

Asked by hakim johari

Hi

I want to open > write > save > close

this is my code:

if exists("collectionRed-1.JPG"):
   openApp("Z:\UiTM\\fyp\\automation test\\result\\TC_001.txt\")
   type("Collection menu turn to red")
   closeApp("Z:\UiTM\\fyp\\automation test\\result\\TC_001.txt\")

but I have an error

[error] App.open failed: Z:\UiTM\fyp\automation test\result\\TC_001.txt not found

Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

A .txt file cannot be opened this way.

You have to issue a start command using run.

But why do you not use the user logging feature for this?

Revision history for this message
hakim johari (hakim-johari) said :
#2

I didn't know sikuli have that feature

Can u show me the coding example for the user logging feature?

Thanks a bunch

Revision history for this message
hakim johari (hakim-johari) said :
#3

thanks I found how to do the logging feature but I got an error with the script

this is my script:

import logging; reload(logging)

#create a new logging instance
logger = logging.getLogger("MyLogger")

#set the file to log to
logger.addHandler(r"Z:\UiTM\fyp\automation test\logging\test.log")
**For this I cannot use fileHandler because it says that the [error] AttributeError ( 'Logger' object has no attribute 'fileHandler' ) and that is why I use addHandler**

#set the logging level, DEBUG is the most verbose level
logger.setLevel(logging.DEBUG)

logger.info("We are starting now") **This is where the error are**

find("afalwearBase-1.JPG")
hover("collectionWhite-2.JPG")
exists("collectionRed.JPG")

def functionInMyScript():
     logger.debug("entering functionInMyScript()")
     # do something that might fail
     hover("collectionWhite-2.JPG")
     exists("menRed.JPG")
     logger.debug("leaving functionInMyScript()")

try:
    functionInMyScript()
    logger.debug("Function call succeeded")
except:
    logger.error("Function call failed") **And also here**

Error for both is:

[error] AttributeError ( 'str' object has no attribute 'level' )
[error] --- Traceback --- error source first line: module ( function ) statement 1280: __init__ ( handle ) File "C:\Users\Papa\Downloads\sikulix.jar\Lib\logging\__init__.py", line 1319, in callHandlers
1177: __init__ ( error ) File "C:\Users\Papa\Downloads\sikulix.jar\Lib\logging\__init__.py", line 1270, in _log
[error] --- Traceback --- end --------------

Revision history for this message
masuo (masuo-ohara) said :
#4

Can you help with this problem?

Provide an answer of your own, or ask hakim johari for more information if necessary.

To post a message you must log in.