简体   繁体   English

如何在执行期间查看sikuli日志?

[英]How to see sikuli logs during execution?

I'm trying to output some debug info in a Sikuli script using print but I can see this info only after the script has finished execution because the IDE hides itself while the script is running. 我正在尝试使用print在Sikuli脚本中输出一些调试信息但我只能在脚本执行完毕后才能看到此信息,因为IDE在脚本运行时隐藏了自己。 Is there a way to see those logs during execution? 有没有办法在执行期间查看这些日志? Like outputting this info to console or (better) not hiding IDE during execution? 就像将此信息输出到控制台或(更好)在执行期间不隐藏IDE一样?

(1) You could use a pop-up: (1)您可以使用弹出窗口:

popup("Hello World")

(2) You can use Jython's File IO (2)您可以使用Jython的File IO

f = open("myLogfile.txt", 'a')
f.write("Log Message")
f.close()

Now if you open the log file in a text editor that warns about changes made to the file (ie NOT Notepad.exe), you can then see your print statements every time the file is appended by your script. 现在,如果您在文本编辑器中打开日志文件以警告对文件所做的更改(即NOT Notepad.exe),则每次脚本附加文件时都可以看到打印语句。

You cannot hide the IDE in background during script execution. 在脚本执行期间,您无法在后台隐藏IDE。 However,there's an alternative to view the logs. 但是,还有一种查看日志的替代方法。

You can install the package which launches your sikuli via command prompt(sikuli-script.jar), refer to https://launchpad.net/raiman/+download 您可以通过命令提示符(sikuli-script.jar)安装启动sikuli的软件包,请参阅https://launchpad.net/raiman/+download

you won't need the IDE to launch your scripts this way. 您不需要IDE以这种方式启动脚本。

Now after changing necessary environment settings you can type-in simple path like "java -jar %Sikuli_Home%\\sikuli-script.jar -r %Sikuli_Scripts%\\main.sikuli" in cmd and get started. 现在,在更改了必要的环境设置后,您可以在cmd中键入简单路径,例如“java -jar%Sikuli_Home%\\ sikuli-script.jar -r%Sikuli_Scripts%\\ main.sikuli”并开始使用。

here 'main' is my driver script where I have imported my modules under single .sikuli folder (main.sikuli) you can have any file name like abc.sikuli 这里'main'是我的驱动程序脚本,我在单个.sikuli文件夹(main.sikuli)下导入我的模块你可以有任何文件名,如abc.sikuli

(here you need to store your path in a variable like ,path = os.environ['Sikuli_Scripts']) (这里你需要将你的路径存储在变量中,如path = os.environ ['Sikuli_Scripts'])

Also ,it is a good practice to launch applications creating batch files and accessing files using relative path. 此外,最好使用相对路径启动创建批处理文件和访问文件的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM