task scheduler

Hi,

How can I run the test cases/suites I created automatically? i.e. with task scheduler. In order for the tests to run daily.

Thanks

Hi Mark,

There’s no such function in Katalon (as far as I know) . But I managed to do it with Windows taskscheduler (or any other) and a batchfile. With Katalon you can generate a CMD script (https://docs.katalon.com/display/KD/Console+Mode+Execution). Paste the script in a batchfile and use a taskscheduler to do the rest. My batchfile looks like this (the part from “katalon studio”\katalon-run…browserType=“Chrome” is generated by CMD script by Katalon):

@echo on
users\downloads"katalon studio"\katalon -runMode=console -projectPath=“C:\Users\Downloads\Katalon Studio\Katalon Studio Projects\Regressiontest studentwebsite\Testcases_general.prj” -reportFolder="…/…/Desktop" -reportFileName=“report” -sendMail="youname@yourmail.com;" -retry=0 -testSuitePath=“Test Suites/New Test Suite-1” -browserType=“Chrome”

1 Like

Hi there,

I cannot seem to get this to work. I generated the CMD script from Katalon, then pasted it to notepad with the .bat extension. Then I created a new task in Task Scheduler, but nothing seems to happen. This is how my batch file looks like:

katalon -noSplash -runMode=console -consoleLog -projectPath=“C:\Users\902372\Dropbox\Eneco\Katalon Studio\MEZ Portal\MEZ Portal.prj” -retry=0 -testSuitePath=“Test Suites/Inloggen” -executionProfile=“default” -browserType=“Chrome”

Any tips?
Thanks in advance.

Does the task work when you run it from Task Scheduler?

You can also look in Event Viewer and enable the history section in Scheduler to track the outcome of a task.

this is a typical mistake.
mostly, the .bat file the user made it is not located in the same location with katalon instalation … or the WORKDIR is different.
simply provide the absolute path to katalon.exe binary in the script to avoid such ‘issues’
(alternate - add the katalon instalation folder to the PATH environment variable)

1 Like

Hi there,

It does run, but I do not see a report made by katalon studio. So I cannot see if the test was succesful.

the script is running, indeed.
but the script is wrong, not actualy launching katalon.
so, fix the script first, try to execute it manualy from command prompt/ powershell and after check the scheduler again
after a succesfull run you should find the generated report in the project folder > reports

Hi Ibus,

Let me give you some contxt. The bat file is now located in the same location as the Katalon installation, which is on a windows virtual machine. The project file however, was indeed located in another directory, on dropbox file so that I could use the same file on both my mac and my Windows machine. I have now relocated the project file to the same location where my Katalon installation is, windows Virtual Machine, and still cannot see any kind of prove in katalon that my testsuite was executed. I do see on the Task Scheduler logs.

This is how my bat file looks like now:

katalon -noSplash -runMode=console -consoleLog -projectPath=“C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\MEZ Portal.prj” -retry=0 -testSuitePath=“Test Suites/Inloggen” -reportFolder=“C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\Reports\Inloggen” -reportFileName=“report” -executionProfile=“default” -browserType=“Chrome”

Another question, what is the “absolute path” you mentioned in your reply?

Hi Ibus,

That’s exactly my issue, it is not launching Katalon

You need to add the path of you katalon.exe file so the script can open and run in katalon. Without this, as you have experienced, its running without opening the executable file.

So, it would be something like this:

C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\Katalon.exe -noSplash -runMode=console -consoleLog -projectPath=“C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\MEZ Portal.prj”
-retry=0 -testSuitePath=“Test Suites/Inloggen” -reportFolder=“C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\Reports\Inloggen”
-reportFileName=“report” -sendMail="jerson.martinez@eneco.com;" -executionProfile=“default” -browserType=“Chrome”

instead of:

Katalon -noSplash -runMode=console -consoleLog -projectPath=“C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\MEZ Portal.prj”
-retry=0 -testSuitePath=“Test Suites/Inloggen” -reportFolder=“C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\Reports\Inloggen”
-reportFileName=“report” -sendMail="jerson.martinez@eneco.com;" -executionProfile=“default” -browserType=“Chrome”

@jerson.martinez even if you move the .bat to the project dir is still wrong.
and even if you put the .bat in the same folder with katalon may be still wrong because 2nd case i described (workdir is different when task scheduler is executing it)
so, yeah, you have to put that full c:\blah\blah\katalon.exe path in the script as you posted and should be fine
the project can be anywhere, provided you put the right path in the comand options

1 Like

@Ibus I’m on step further, It does try to launch but the I get this error:

This what i see in the log:
!SESSION 2019-05-08 11:33:03.787 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_181
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -runMode=console -projectPath=C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\MEZ Portal.prj -retry=0 -testSuitePath=Test Suites/Inloggen -reportFolder=C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\Reports\Inloggen -reportFileName=ÔÇ£reportÔÇØ -sendMail=jerson.martinez@eneco.com; -executionProfile=default -browserType=Chrome
Command-line arguments: -os win32 -ws win32 -arch x86_64 -data config -runMode=console -consoleLog -projectPath=C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\MEZ Portal.prj -retry=0 -testSuitePath=Test Suites/Inloggen -reportFolder=C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\MEZ Portal\Reports\Inloggen -reportFileName=ÔÇ£reportÔÇØ -sendMail=jerson.martinez@eneco.com; -executionProfile=default -browserType=Chrome

!ENTRY org.eclipse.osgi 4 0 2019-05-08 11:33:05.649
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: The platform metadata area could not be written: C:\Windows\System32\config.metadata. By default the platform writes its content
under the current working directory when the platform is launched. Use the -data parameter to
specify a different content area for the platform.
at org.eclipse.core.internal.runtime.DataArea.assertLocationInitialized(DataArea.java:61)
at org.eclipse.core.internal.runtime.DataArea.getStateLocation(DataArea.java:129)
at org.eclipse.core.internal.preferences.InstancePreferences.getBaseLocation(InstancePreferences.java:44)
at org.eclipse.core.internal.preferences.InstancePreferences.initializeChildren(InstancePreferences.java:209)
at org.eclipse.core.internal.preferences.InstancePreferences.(InstancePreferences.java:59)
at org.eclipse.core.internal.preferences.InstancePreferences.internalCreate(InstancePreferences.java:220)

chh … looks like taskscheduler is stupid and is working by default in a location where the script does not have write permision (needed by eclipse, another stupid). add a cd command in the script to change the folder to a different location,before the line running katalon. script should look like:

cd c:\path\to\project
c:\blah\blah\katalon.exe -otherBlah blah

alternate,use:

cd C:\path\where\katalon\is\installed
katalon blah blah blah
1 Like

@Ibus Dude, it worked!! You’re a lifesaver!!

So my script turned out like this now:

cd C:\Users\902372\Katalon_Studio_Windows_64-6.1.3
C:\Users\902372\Katalon_Studio_Windows_64-6.1.3\Katalon.exe -noSplash -runMode=console -consoleLog -projectPath="C:\Users\902372\

I cannot thank you enough m8!
Have a good one!

2 Likes

glad to hear it worked!

I got lost.
What do I need to do after generating a CMD script?

ahem … run it? or schedule it?

@Ibus to run the test suites.

seriously i don’t understand where you are blocked. you have the command, run it …