-
Notifications
You must be signed in to change notification settings - Fork 357
ZZZ some interesting stuff
Raimund Hocke edited this page Nov 25, 2019
·
3 revisions
worth to read
- http://maven.apache.org/plugin-developers/index.html
- https://github.com/antlr/stringtemplate4
- https://github.com/antlr/antlr4
Windows: get an admin command window
For your information, my workaround on the PC where clicks don't work anymore, is to start SIKULIX via that .bat script: that works fine in all the cases.
Fun fact: On the PC where I don't have the click issue, this particular script does not work. SIKULIX fails clicking in that case. So I need to be careful how I start SIKULIX on every computer.
@echo off
:: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:: BatchGotAdmin (Run as Admin code ends)
:: Your codes should start from the following line
java -jar C:\temp\SikuliX\sikulix.jar
Sikuli logs to HTML test runner report
----------------------- a possible solution
I actually found a solution on how to write my custom logs into html test runner report.For this you need: sikulixIDE,HTMLTestreport and unittest. So I have a file, testRunner for example form where I'm running the tests. Those are organized via unittest.TestSuite and then executed with HTMLTestRunner like this:
if __name__ == "__main__":
suite = suite()
unittest.TextTestRunner(verbosity = 2)
output = open(r"your html.file report location","w+")
runner = HTMLTestRunner.HTMLTestRunner(stream=output, title='Test Report', description='Logfiles')
runner.run(suite)
The most important thing is the Logger file, let's say MyLogger, the code looks like this:
from sikuli import *
# Severity of logged behaviour
LEVEL_FATAL, LEVEL_WARNING, LEVEL_INFO = range(0, 3)
class Messenger:
@staticmethod
def Log(severity,message):
switcher = {
LEVEL_FATAL: 'FATAL ERROR',
LEVEL_WARNING: 'WARNING',
LEVEL_INFO: 'INFO',
}
severityMessage = switcher.get(severity, "MESSAGE")
messageLong = severityMessage + message
if severity == LEVEL_FATAL:
print Exception(messageLong)
else:
print messageLong
Now just import MyLogger file into your tests or where you need this logger and use it like this:
import MyLogger
reload(MyLogger)
#your code
//logger call example for fatal
MyLogger.Messenger.Log(MyLogger.LEVEL_FATAL,'your message')
Now when the htmlfile is generated by HTMLTestreport, the logs should be displayed there for each test(ofc based on how you organized them in your suites in TestRunner file.
I hope this works for you as for me it's really good and helpful.
---------------------------------------------------------------------------------------------------------
Hello, I am using sikuli IDE to automate a desktop app. I'm also using html-testRunner 1.1.2 to generate reports and the sikuli logger to write to a file. Here is my code for this:
Settings.UserLogs=True
Settings.UserLogPrefix="LOG"
Settings.UserLogTime=True
Debug.setUserLogFile("path\TestRunnerLogs.txt")
Debug.user('some text')
How can I write my logs directly to the HTML file generated by htlm test runner? And if possible can i write the logs separately for each test?