Every automation engineer working with OATS needs to know how to execute oats scripts in command line. It is inevitable when working in real time projects one wishes to run scripts in batch mode. In this article you will know how to do the same.
OATS team had provided us with a bat file called “runScript.bat”, this file is present at following location “OATS installation directory\openScript” , in my case it is “C:\OracleATS\openScript\runScript.bat”, we need to pass in the jwg file location.
The most simple syntax to call an OATS scripts is as follows
c:\OracleATS\openScript>runScript.bat "path to the script folder\scriptname.jwg" Example: c:\OracleATS\openScript>runScript.bat "C:\Training\RecordWithOL\RecordWithOL.jwg"
There are more options available for runScript.bat file, that is you can specify number of times a script needs to run. Following is an example for the same.
Example: c:\OracleATS\openScript>runScript.bat "C:\Training\Sctripts\MasterDriver\MasterDriver.jwg" -iterations 3
The MasterDriver script is executed for three times.
Similarly, you can provide many script settings through command line options for runScript.bat. You need to provide “-browser.type InternetExplorer” option, if you want to execute a script in an internet explorer browser.
You need to know that there is a limitation for “runScript.bat” file, it can accept a maximum of 9 command line arguments. So, if you have to set more than 9 script settings you need to use “-propertiesPath filelocation” option.
Pass script settings through command line
Create a “.properties” file and include all script settings that you wish to have. The following example tells you how to pass the properties file as a command line argument.
Example: C:\OracleATS\openScript>runScript.bat "C:\Training\Sctripts\MasterDriver\MasterDriver.jwg" -propertiesPath "C:\Training\Sctripts\MasterDriver\settings.properties"
Lke -propertiesPath there are some good number of options available to run from command prompt. We have listed and explained the top 11 command prompt options of OATS for your convenience.
There are is a huge list of script settings that you can work with, refer to the following link if you want to know more about it.
Create your bat file to trigger scripts
Also, you can create a “.bat” file with the above command(s), calling this new bat file will trigger the script executions.
In case you observe some weird behavior like, script triggers browser but the remaining steps do not execute. Solution is to launch command prompt with an elevated privileges.
Sample code for bat file can be as below:
cd\ cd OracleATS\openScript runScript.bat "c:\OracleATS\OFT\FirstEBSScript\FirstEBSScript.jwg"
This article really helps. ussimuvul.
Thank you Smaran for liking it, hope it is useful for you 🙂
Thanks for sharing your Knowledge. Its really useful.
You are welcome, I am glad that you feel it is useful.
Thank for sharing your information.
When i run through command prompt, it is getting some error like “oracle.oats.scripting.modules.webdom.common.api.exception.BrowserHelperException: Cannot get a connection from helper after 120 seconds” . please help me on this.
IE version 11
OATS version 13.2
Thanks
I would recommend you to run the command prompt with elevated privileges, that is right click on your bat file and select “Run As Administrator” option and it should work.
There is also an option to set command prompt to open in Administrator mode by default. I will share with you an article soon, but for now you can right click on command prompt and select “Run As Administrator” it should solve your issue.
Thanks Srinivas ,
please provide to set command prompt to open in Administrator mode by default.
Thanks
There you go Steps how to always run command prompt with administrator privileges
Thanks you srinivas
If I am check for a String on a web page after login, how can I make sure this worked if running ATS script on command line?
It will behave the same way whether you run it directly from openscript tool or from command prompt.
May be i did misunderstand requirement, could you please provide more details
Hi Srinivas,
I am unable to execute jwg file from cygwin commandline.
14:45:06,546 WARN [JwgRepositoryService] No repository path found, using default. repository=OATS
14:45:06,594 WARN [JwgRepositoryService] No repository path found, using default. repository=OATS
14:45:06,595 WARN [JwgRepositoryService] No repository path found, using default. repository=OATS
14:45:06,595 WARN [JwgRepositoryService] No repository path found, using default. repository=OATS
14:45:06,595 WARN [JwgRepositoryService] No repository path found, using default. repository=OATS
14:45:06,647 WARN [JwgRepositoryService] No repository path found, using default. repository=OATS
14:45:06,654 WARN [JwgAndAssetsReader] Following assets were not found:
(1)Script “Request Fluke AR Invoices Generation Request”: asset with alias “GENLIB”
(2)Script “Request Fluke AR Invoices Generation Request”: asset with alias “LOGINLIB_6”
(3)Script “Request Fluke AR Invoices Generation Request”: asset with alias “GENEBSLIB_1”
(4)Script “Request Fluke AR Invoices Generation Request”: asset with alias “EBSLibrary”
(5)Script “Request Fluke AR Invoices Generation Request”: asset with alias “WEBTABLELIB”
(6)Script “MASTERDRIVE”: asset with alias “GENLIB”
It clearly says in the error message that it cannot identify the different function libraries. You may have to make sure the function libraries are associated properly
Hello Srinivas,
In the last example, can I run multiple scripts in my own bat file? For example:
cd\
cd OracleATS\openScript
runScript.bat “c:\OracleATS\OFT\FirstEBSScript\FirstEBSScript.jwg”
runScript.bat “c:\OracleATS\OFT\FirstEBSScript\SecondEBSScript.jwg”
runScript.bat “c:\OracleATS\OFT\FirstEBSScript\ThirdEBSScript.jwg”
I am trying to run a test set from the command line since it seems so much faster.
Thanks in advance.
Regards,
Jan
Hi Jan,
Thank you so much for reaching out to us, Yes it is quite possible to execute the way you mentioned. But also the other way is you create a driver script which in turn triggers the execution of a desired set of scripts. So this master driver script can basically take an excel as input with list of the automated scripts, and have an ability mark as which subset of scripts that you plan to execute.
If implemented this way, the bat file will never need a modification, that is later you want to run only 2 scripts or you want to 10 scripts, with your approach you should always go to the bat file and update the same to execute.
But with the approach i just mentioned, you just need to mark Yes / No against each script in an excel and that doesn’t need any changes in bat file code.
Hope this helps.
Thank you once again for reaching to us.
How do I run multiple scripts and count how many have passed / fail in this scenario
If you create a master driver scripts in OATS and then execute that master driver from command line, it executes all the scripts.
And finally you will see the result file for a master driver, which has all the child scripts related results as well. This will be like a table that you can see. But if you want a summary or something that is not available out of the box. Also most of the times the results that we see in OATS are too detailed and may not be user friendly for a summary view. In these cases we generally create a separate results view or a custom results view generator.
Some people even integrate the Extent Report if required.
Some people create their own report generation as well.
It all depends on how much time and what kind of customizations you are looking at.
Hope this answers your query. Please do revert to us in case of any more queries. we are happy to give you a response