18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Batch mode execution on Mac OS X
Hi All,
I went through the following post and created batch mode execution of multiple test cases on Windows it does works fine. http://sahi.co.in/w/Running+multiple+tests+in+batch+mode
But, I need to create a similar batch mode execution on Mac. For example, if we consider safari browser:
java -cp ..\lib\ant-sahi.jar net.sf.sahi.test.TestRunner "C:\Sahi\userdata\scripts\Vita_G3_Framework\Test_Scripts\Execution.suite" "C:\Program Files\Safari\Safari.exe" "http://s2k3-2106" "C:\Sahi\userdata\scripts\Vita_G3_Framework\Results\Safari" Localhost 9999 1 "Safari.exe" "Safari.exe" "-noframemerging"
I tried changing the directory to "/Users/VCadmin/Sahi/userdata/scripts/ ect /ect" and execute on Mac terminal, But this does not work.
How can i modify it to run on Mac machine? [ Since, C:\ and stuff don’t work on Mac]
I went through the following post and created batch mode execution of multiple test cases on Windows it does works fine. http://sahi.co.in/w/Running+multiple+tests+in+batch+mode
But, I need to create a similar batch mode execution on Mac. For example, if we consider safari browser:
java -cp ..\lib\ant-sahi.jar net.sf.sahi.test.TestRunner "C:\Sahi\userdata\scripts\Vita_G3_Framework\Test_Scripts\Execution.suite" "C:\Program Files\Safari\Safari.exe" "http://s2k3-2106" "C:\Sahi\userdata\scripts\Vita_G3_Framework\Results\Safari" Localhost 9999 1 "Safari.exe" "Safari.exe" "-noframemerging"
I tried changing the directory to "/Users/VCadmin/Sahi/userdata/scripts/ ect /ect" and execute on Mac terminal, But this does not work.
How can i modify it to run on Mac machine? [ Since, C:\ and stuff don’t work on Mac]
Comments
Can you please give a example as to how to execute a test Suit on Mac OS X. I went through the documention and examples provided by sahi. Most of the examples are only for Windows. There are not many Mac or Linux examples.
It would be really helpfull, if we have examples or documentaion for Mac and Linux also.
As stated here: http://sahi.co.in/w/Running+multiple+tests+in+batch+mode, you need to use the correct paths to the Safari executable
Try:
If "open -a Safari" does not work, try with "open" or "/full/path/to/Safari"
Regards,
Narayan
For other sahi users commands to work on Mac:
switch over to sahi bin directory:
cd sahi
cd bin
Safari Browser:
java -cp ../lib/ant-sahi.jar net.sf.sahi.test.TestRunner "scripts/Vita_G3_Framework/Test_Scripts/Execution.suite" "open -a Safari" "http://s2k3-2106.local/" "scripts/Vita_G3_Framework/Results/Safari" Localhost 9999 1 "Safari" "Safari" "-noframemerging"
Firefox Browser:
java -cp ../lib/ant-sahi.jar net.sf.sahi.test.TestRunner "scripts/Vita_G3_Framework/Test_Scripts/Execution.suite" "open -a Firefox" "http://s2k3-2106.local/" "scripts/Vita_G3_Framework/Results/Firefox" Localhost 9999 1 "Firefox" "Firefox" "-profile browser/ff/profiles/sahi$threadNo -no-remote"
Chrome:
java -cp ../lib/ant-sahi.jar net.sf.sahi.test.TestRunner "scripts/Vita_G3_Framework/Test_Scripts/Execution.suite" "open -a 'Google Chrome' " "http://s2k3-2106.local/" "scripts/Vita_G3_Framework/Results/Chrome" Localhost 9999 1 "Google Chrome" "Google Chrome" "--user-data-dir=$userDir/browser/chrome/profiles/sahi$threadNo --proxy-server=localhost:9999 --disable-popup-blocking"
[For Chrome - You need to use (open -a 'Google Chrome') in single quotes]. Ensure your proxy settings are set right.
Batch mode execution works on Mac.
Regards,
Narayan
Thanks for the usefull tips for using Sahi on MAC. It works great!
I am still facing an issue using sahi in batch mode on MAC. The firefox profiles doesn't seem to work as the proxy settings are not done automatically when using the batch mode. Also I tried running Sahi on Safari but am getting out of memory error. I am sure I am missing out something. Please share if you have any insights.
Regards,
Pankaj Kumar
You hit the same error as i got it. Even i struggled with this error. To be honest, i dono what’s going wrong here. I feel there might be something in depth we are missing or there might be a bug in Sahi or its something silly we are missing. (Narayan can put a light on this).
First Part:
I will tell you what I did to overcome this:
1. Stop sahi proxy server.
2. Change settings on safari such that it does not use proxy server.
3. Close the browser.
4. Launch browser and connect to some website like google.com
5. Once google launches without using proxy server.
6. Don’t close the browser, change back ur browser settings to use sahi proxy server .
7. Go back to the terminal and start sahi.sh file from bin directory.
8. Now launch you application, It will not throw Java out of memory error on console.
9. Once its starts working then any number of times you can open and close browser no-issues.
Second Part:
When you are running scripts on windows you just call batch file which remains in the same bin directory until it completes execution on all browsers. But that’s not the case with Mac.
After you complete execution on one browser, you need to set back the execution path to bin directory:
I am sharing the code for .sh file i had written for my application:
_________________________________________________________________
#!/bin/bash
echo "Executing Automation Suite"
cd ~
cd Sahi/bin
echo "Execution on Safari"
java -cp ../lib/ant-sahi.jar net.sf.sahi.test.TestRunner "scripts/Vita_G3_Framework/Test_Scripts/Execution.suite" "open -a Safari" "http://s2k3-2106.verdad.local/" "scripts/Vita_G3_Framework/Results/Safari" Localhost 9999 1 "Safari" "Safari" "-noframemerging"
echo "Execution on Firefox"
cd ~
cd Sahi/bin
java -cp ../lib/ant-sahi.jar net.sf.sahi.test.TestRunner "scripts/Vita_G3_Framework/Test_Scripts/Execution.suite" "open -a Firefox" "http://s2k3-2106.verdad.local/" "scripts/Vita_G3_Framework/Results/Firefox" Localhost 9999 1 "Firefox" "Firefox" "-profile browser/ff/profiles/sahi$threadNo -no-remote"
echo "Execution on Google Chrome"
cd ~
cd Sahi/bin
java -cp ../lib/ant-sahi.jar net.sf.sahi.test.TestRunner "scripts/Vita_G3_Framework/Test_Scripts/Execution.suite" "open -a 'Google Chrome' " "http://s2k3-2106.verdad.local/" "scripts/Vita_G3_Framework/Results/Chrome" Localhost 9999 1 "Google Chrome" "Google Chrome" "--user-data-dir=$userDir/browser/chrome/profiles/sahi$threadNo --proxy-server=localhost:9999 --disable-popup-blocking"
echos "Completed execution on all 3 browsers"
cd ~
cd Sahi/userdata/Scripts/Vita_G3_Framework/Test_Scripts - (Replace this with your path)
_____________________________________________________________________________
You can execute this script from any where but change the paths accordingly.
Launch firefox manually once and check if is it launching. while scripting be carefull with case. Mac is case sensitive.
We can successfuly do a batch mode execution, Give a try !!
Thanks for your valuable inputs. I tried the steps you have suggested but it is not working for me. The strange thing is that I was able to execute my scripts individually through the Sahi controller earlier. After I tried my hands on batch execution using sahi suites I started getting the errors like: But now i get the same error even if try to execute a single script through the sahi controller.
This is happenning on both Firefox as well as Safari.
I also tried fiddling with the heap size using the -Xms and -Xmx parameters.
I updated my sahi.sh like this: Please let me know where I am doing it wrong or any suggestions/workrounds.
This error message provided here is just a snippet of the long error message. I can mail the complete error message if needed.
Regards,
Pankaj
Got the problem resolved for the single script execution through Sahi controller.
Honestly speaking the problem is still not clear to me but what I did was update Java, restart the MAC, and download fresh copy of Sahi. This worked for me. Now I will try to work upon the suite/batch thing. Lets see which way the cookie crumbles!
I will keep posting my findings.
Regards,
Pankaj Kumar
We configure the browser to use Sahi as its proxy.
On Mac, Java uses the system wide proxy. So now, Browser and Java both use Sahi as its proxy. (What wasimhbr noticed. If you configure the proxy and then start Java, it will use Sahi as its proxy too. If you change the proxy after starting Java, then things are fine)
It should have been
browser -> Sahi -> Java (urlconnection) -> Website
but it has become
browser -> Sahi -> Java (urlconnection picks Sahi proxy now) -> Sahi
This is where the recursion comes in.
To fix this, open userdata.properties and set these properties:
Basically we are forcing Java to use a direct connection here.
Let me know if this fixes your issue.
Regards,
Narayan
I tried the same and was able to execute the batch/suite. But I had to keep
ext.http.proxy.enable=false
and also had to follow the sequence mentioned by wasimhbr. The only challenge remaining is to use profiles to automatically set firefox proxy settings.
I have the following shell script that will automatically invoke sahi proxy and then launch the suite runner: This works fine if I have already set the Firefox proxy to point to localhost:9999
But the suite execution on Safari through my shell script still gives the out of memory error.
Regards,
Pankaj Kumar
For example, i'm trying to run test under Safari (running from sahi/bin dir):
after this, i'm getting a message from which i think that everything is right in syntax:
In other terminal tab, where Sahi server is running, i get:
So suite file was accessed and Sahi tells that it's running scripts, but browaser not opens and nothing happens.
After some time, a log file appears telling:
I'm not getting any other error messages so i don't understand what exactly i make wrong. Can you please help me? ( i removed site URLs from post because forum not allows me to post them)
1. If you are trying on Safari Browser, you need to change the browser security settings to always accept cookies.
2. Just have a look at relative paths.
3. Try launching browser from terminal and check whether you are able to launch your application.
4. Execute a single script before running a batch script.
5. Re-verify the Sahi proxy settings.
Do ensure that you have followed the instructions provided by wasimhbr (post #7 in this thread) and Narayan (post #10 in this thread).
Regards,
Pankaj
For Safari, browserOptions should be blank.
Regards,
Narayan
I want to do the following on MAC+Safari:
1. Write a shell script that does the following:
> Launch the sahi proxy as a background job
> Run a suite
Now my problem is that if I follow the mentioned sequence I have to first manually set Safari to use sahi as its proxy listening at port 9999. Now if I execute my shell script it goes into an endless loop resulting into Out of memory error. I tried all the suggestions given above, but in vain.
Please give some suggestion.
Regards,
Pankaj Kumar
i moved a step further but i still cannotmake things working for me.
FIrst, browser finally opens (that's good), but only if browserOptions is empty (that relates to FireFox, too, not only to Safari)
Second, when i set proxy options in Safari (on MacOS these are global system proxy options) i getting the same out of memory error already described above. So i'm able to use only FF.
Third, and the worst problem is that Sahi ignores port for some reason when i'm trying to run batch job. I mean, i'm using port 3000 to run my local application that i test and i'm providing URL with port when runnning batch job, but after opening browser, Sahi tries to open URL without port (and of course, cannot reach application). I think it's a bug.
Regards, psylence
I finally managed to run tests, by changing my app port from 3000 to 80, but i still think that it would be greate for Sahi to support custom ports in batch mode, as many developers use them.
psylence