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.
Issue running Sahi script using Python
Hello,
I need to start Sahi and then execute Sahi script using Python. I'm calling testrunner.bat to execute a suite file which contains a single sahi script (first time I'm dealing with Python btw):
import subprocess as sp
sp.Popen(r"C:\sahi\userdata\bin\start_dashboard.bat", cwd="C:\\sahi\\userdata\\bin")
time.sleep(3)
sp.Popen([r"C:\sahi\userdata\bin\testrunner.bat", r"BO/Scripts/Liability_Report/start_test.suite", r"http://sahi.example.com/_s_/dyn/Driver_initialized", r"firefox"], cwd=r"C:\sahi\userdata\bin")
A couple of weird things happen when I run this script. First Sahi Dashboard fails to find any of the browsers I have installed because the paths it is looking at are incorrect (note how it adds extra "(x86)"):
...
Reading browser types from:
\sahi\userdata\config\browser_types.xml
Firefox was not found at C:\Program Files (x86) (x86)\Mozilla Firefox\firefox.ex
e
Safari was not found at C:\Program Files (x86) (x86)\Safari\Safari.exe
Chrome was not found at C:\Program Files (x86) (x86)\Google\Chrome\Application\c
hrome.exe
IE 10 was not found at C:\Program Files (x86) (x86)\Internet Explorer\iexplore.e
xe
Opera was not found at C:\Program Files (x86)\Opera x64\opera.exe
...
This I was able to fix by removing "(x86)" from browser_types.xml (where possible). Only for Opera which is originally installed at "C:\Program Files\" I used its short DOS path because there's no "(x86)"
Anyways, the other issue is where I'm stuck at. The Sahi script within the suite file fails with the following error:
ERROR
exception: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
...
That's the very first row of the script where I'm trying to connect to some Excel file (I used _alert before and after to be sure):
var $config = _getDB("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}; DBQ=C:\\sahi\\userdata\\scripts\\config.xlsx;readOnly=false", "", "");
My Sahi script works perfectly when I start it manually from the Sahi controller but it fails when started from the Python script. If I run testrunner.bat for my suite file directly from Command Prompt like:
C:\sahi\userdata\bin>testrunner.bat BO/Scripts/Liability_Report/start_test.suite http://sahi.example.com/_s_/dyn/Driver_initialized firefox
the sahi script within the suite file is not executed at all and there is no log available to see any error. Here is the message that is logged in Command Prompt:
browserType=firefox
baseURL=http://sahi.example.com/_s_/dyn/Driver_initialized
host=localhost
port=9999
threads=5
useSingleSession=true
suiteName = scripts/BO/Scripts/Liability_Report/start_test.suite
base = http://sahi.example.com/_s_/dyn/Driver_initialized
sahiHost = localhost
port = 9999
threads = 5
browserType = firefox
this.isSingleSession == true
Added shutdown hook.
http://localhost:9999/_s_/dyn/Suite_start?suite=scripts/BO/Scripts/Liabili
ty_Report%2Fstart_test.suite&base=http%3A%2F%2Fsahi.example.com%2F_s_%2Fdyn%2FDr
iver_initialized&threads=5&sahisid=sahi_a25d588006f9e044ed095000c817a3df7654&bro
wserType=firefox&useSingleSession=true&html=
FAILURE
Shutting down ...
I'm using Sahi install_sahi_v44_20130429.
Please, can anyone who has experienced the same or similar issue and managed to solve it share their solution? Thank you.
P.S. Sorry for the long post
Regards,
Iskren
I need to start Sahi and then execute Sahi script using Python. I'm calling testrunner.bat to execute a suite file which contains a single sahi script (first time I'm dealing with Python btw):
import subprocess as sp
sp.Popen(r"C:\sahi\userdata\bin\start_dashboard.bat", cwd="C:\\sahi\\userdata\\bin")
time.sleep(3)
sp.Popen([r"C:\sahi\userdata\bin\testrunner.bat", r"BO/Scripts/Liability_Report/start_test.suite", r"http://sahi.example.com/_s_/dyn/Driver_initialized", r"firefox"], cwd=r"C:\sahi\userdata\bin")
A couple of weird things happen when I run this script. First Sahi Dashboard fails to find any of the browsers I have installed because the paths it is looking at are incorrect (note how it adds extra "(x86)"):
...
Reading browser types from:
Firefox was not found at C:\Program Files (x86) (x86)\Mozilla Firefox\firefox.ex
e
Safari was not found at C:\Program Files (x86) (x86)\Safari\Safari.exe
Chrome was not found at C:\Program Files (x86) (x86)\Google\Chrome\Application\c
hrome.exe
IE 10 was not found at C:\Program Files (x86) (x86)\Internet Explorer\iexplore.e
xe
Opera was not found at C:\Program Files (x86)\Opera x64\opera.exe
...
This I was able to fix by removing "(x86)" from browser_types.xml (where possible). Only for Opera which is originally installed at "C:\Program Files\" I used its short DOS path because there's no "(x86)"
Anyways, the other issue is where I'm stuck at. The Sahi script within the suite file fails with the following error:
ERROR
exception: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
...
That's the very first row of the script where I'm trying to connect to some Excel file (I used _alert before and after to be sure):
var $config = _getDB("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}; DBQ=C:\\sahi\\userdata\\scripts\\config.xlsx;readOnly=false", "", "");
My Sahi script works perfectly when I start it manually from the Sahi controller but it fails when started from the Python script. If I run testrunner.bat for my suite file directly from Command Prompt like:
C:\sahi\userdata\bin>testrunner.bat BO/Scripts/Liability_Report/start_test.suite http://sahi.example.com/_s_/dyn/Driver_initialized firefox
the sahi script within the suite file is not executed at all and there is no log available to see any error. Here is the message that is logged in Command Prompt:
browserType=firefox
baseURL=http://sahi.example.com/_s_/dyn/Driver_initialized
host=localhost
port=9999
threads=5
useSingleSession=true
suiteName = scripts/BO/Scripts/Liability_Report/start_test.suite
base = http://sahi.example.com/_s_/dyn/Driver_initialized
sahiHost = localhost
port = 9999
threads = 5
browserType = firefox
this.isSingleSession == true
Added shutdown hook.
http://localhost:9999/_s_/dyn/Suite_start?suite=scripts/BO/Scripts/Liabili
ty_Report%2Fstart_test.suite&base=http%3A%2F%2Fsahi.example.com%2F_s_%2Fdyn%2FDr
iver_initialized&threads=5&sahisid=sahi_a25d588006f9e044ed095000c817a3df7654&bro
wserType=firefox&useSingleSession=true&html=
FAILURE
Shutting down ...
I'm using Sahi install_sahi_v44_20130429.
Please, can anyone who has experienced the same or similar issue and managed to solve it share their solution? Thank you.
P.S. Sorry for the long post
Regards,
Iskren
Answers
I've done some testing and found that the issue is coming from this row in the Python script (the testrunner.bat call works if I have started Sahi manully before that):
sp.Popen(r"C:\sahi\userdata\bin\start_dashboard.bat", cwd="C:\\sahi\\userdata\\bin")
This actually works to the point that Sahi dashboard is started but then the browsers issue and the DB source not found error suggest that something is not the same as if I started it manually
Regards,
Iskren
Issue was from the fact that I have 32 bit python and when Sahi dashboard is started by the python script it uses the 32 bit Command Prompt. After I have installed the 64 bit python everything worked fine.
Regards,
Iskren