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.
Need different name/password combination with basic authentification
Hello,
I need some ideas how to optimize my usage of this great tool...
Initially I want to test a webserver with basic authentification on some websites. Therefore I found out how to change the settings in userdata.properties and it works fine.
1) My problem now is that I need to test different combinations of username/password. Is there anyhow a possibility to change these settings from a script command whithout stopping the proxy, changing the settings and restarting the proxy?
My favorite szenario would be running a first script with username1/password1, changing both settings from a second script and running a third script with username2/password2.
2) What is the hierarchy of sahi.properties and userdata.properties if they contain different settings? Is userdata.properties "winning" because it is later started?
Any idea is appreciated.
Regards,
Achim
I need some ideas how to optimize my usage of this great tool...
Initially I want to test a webserver with basic authentification on some websites. Therefore I found out how to change the settings in userdata.properties and it works fine.
1) My problem now is that I need to test different combinations of username/password. Is there anyhow a possibility to change these settings from a script command whithout stopping the proxy, changing the settings and restarting the proxy?
My favorite szenario would be running a first script with username1/password1, changing both settings from a second script and running a third script with username2/password2.
2) What is the hierarchy of sahi.properties and userdata.properties if they contain different settings? Is userdata.properties "winning" because it is later started?
Any idea is appreciated.
Regards,
Achim
Comments
Glad you like the Sahi.
1) You specify the username password in userdata.properties only if you are connecting via another proxy and that proxy needs authentication. For pages that need 401 authentication, just navigate to them and you should see a webpage with username/password fields. Sahi converts 401 authentication dialogs into a simple html form. Just record them like a normal form field and it should work.
2) userdata.properties overrides sahi.properties. Sahi will look for a property in userdata.properties first, and only if it does not find it, will look at sahi.properties.
Hope that helps.
Regards,
Narayan
thanks alot for your quick answer.
1) I tried that "normal form field" first but did always run in the following error. So I tried to change the settings and that worked - at least with a fixed username/password combination.
###############
Sahi Error - Stream closed
Either the remote server is down or not reachable
or
You need an external proxy to be configured.
You could configure the external proxy by editing <sahi_root>/config/sahi.properties and setting these properties:
ext.http.proxy.enable=true
ext.http.proxy.host=external_proxy_server_hostname_or_ip
ext.http.proxy.port=external_proxy_server_port
If your proxy needs authorization, you should set these properties too.
ext.http.proxy.auth.enable=true
ext.http.proxy.auth.name=proxy_authorization_username
ext.http.proxy.auth.password=proxy_authorization_password
You should do the same with ext.https settings for https sites.
Stacktrace:
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at net.sf.sahi.util.Utils.getBytes(Utils.java:82)
at net.sf.sahi.util.Utils.getBytes(Utils.java:57)
at net.sf.sahi.RemoteRequestProcessor.process401(RemoteRequestProcessor.java:180)
at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor.java:123)
at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor.java:78)
at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
at java.lang.Thread.run(Unknown Source)
######################
2) Thanks.
Regards,
Achim
I think that was a bug. Could you take this temp build with a fix for this, and let us know if it works for you?
http://sahi.co.in/static/builds/sahi_20100401.zip
If this works, we will add this fix to the next release.
Regards,
Narayan
I will try your fix as soon as Easter holidays allow me to continue my work on Tuesday ;-) and report the results.
Regards,
Achim
I'm back again from my holidays and tried your bugfix version but unfortunatly I don't get it to work. The behavior is now the following:
- After clicking on the link to the encrypted html page I get a window asking for username and password (this ist new). Now I fill both boxes with correct values and click authenticate but the window stays the same with username still filled and password blanked out. I tried different (correct) username/password combinations but nothing happens.
Taking a look at the communication with wireshark it seems to me that within the "get HTTP" request the authorization header is missing. I tried the access with firefox. When using IExplorer without SAHI I can see the authorization header inside the request.
######################################
Maybe the console log helps you more than my explanation:
SAHI_HOME: ..
SAHI_USERDATA_DIR: ..\userdata
SAHI_EXT_CLASS_PATH:
Sahi properties file = C:\Programme\sahi\config\sahi.properties
Sahi user properties file = C:\Programme\sahi\userdata\config\userdata.propertie
s
>>>> Sahi started. Listening on port: 9999
>>>> Configure your browser to use this server and port as its proxy
>>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Cont
roller
realm= /TCPIP.SSI; getRequestingScheme()=basic
06.04.2010 08:29:55 net.sf.sahi.RemoteRequestProcessor process401
INFO: wwwAuthenticate: Basic realm=" /TCPIP.SSI"
06.04.2010 08:29:55 net.sf.sahi.RemoteRequestProcessor process401
INFO: scheme=basic; realm=/TCPIP.SSI
06.04.2010 08:29:55 net.sf.sahi.RemoteRequestProcessor process401
INFO: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at net.sf.sahi.util.Utils.getBytes(Utils.java:84)
at net.sf.sahi.util.Utils.getBytes(Utils.java:59)
at net.sf.sahi.RemoteRequestProcessor.process401(RemoteRequestProcessor.
java:238)
at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
.java:151)
at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
.java:81)
at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
at java.lang.Thread.run(Unknown Source)
>>> Credentials added: /TCPIP.SSI user
realm= /TCPIP.SSI; getRequestingScheme()=basic
06.04.2010 08:30:06 net.sf.sahi.RemoteRequestProcessor process401
INFO: wwwAuthenticate: Basic realm=" /TCPIP.SSI"
06.04.2010 08:30:06 net.sf.sahi.RemoteRequestProcessor process401
INFO: scheme=basic; realm=/TCPIP.SSI
06.04.2010 08:30:06 net.sf.sahi.RemoteRequestProcessor process401
INFO: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at net.sf.sahi.util.Utils.getBytes(Utils.java:84)
at net.sf.sahi.util.Utils.getBytes(Utils.java:59)
at net.sf.sahi.RemoteRequestProcessor.process401(RemoteRequestProcessor.
java:238)
at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
.java:151)
at net.sf.sahi.RemoteRequestProcessor.processHttp(RemoteRequestProcessor
.java:81)
at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
at java.lang.Thread.run(Unknown Source)
#################################
Regards,
Achim
I'm sorry to bother you but do you have any idea what I'm doing wrong?
Regards,
Achim
I just rechecked this and it looks like there is a slight problem in the realm identification in Sahi's code. The realm that Sahi is adding the credentials for is "/TCPIP.SSI" while the actual realm is " /TCPIP.SSI" (with a space at the start).
I will send you a fixed build.
Regards,
Narayan
Could you please try with http://sahi.co.in/static/builds/sahi_20100412.zip and check if it works?
Thanks,
Narayan
You really made a great job finding spaces even in screenshots! Your fix from yesterday works now for the authentification - thank you very much.
Before closing this issue I would like to go back to my initial problem with the request for different combinations of user/password. Once a combination of user/password is set I can't change to another combination because the authentification windows does not appear again. I understand that Sahi can not change settings of a browser or clear a browser cache but maybe there is a possibility of setting the user/password combination directly inside the proxy?
Any other idea is also appreciated.
Thank you,
Achim
does anybody have an idea to the "different user/password combination" topic?
Thank you,
Achim