Skip to content
Get Free Trial

Sahi Configuration (Basic)

Sahi may need a few configuration tweaks to make it work on your system.

Sahi’s Dashboard lists the browsers installed on your systems. Sahi tries to look in default installation locations of different browsers.

If a particular browser, eg. firefox, is installed but not visible on the Dashboard, do the following:

  1. Click All Settings on the Dashboard. The All Settings window opens.

  2. Click Sahi Pro Settings. The Sahi Pro Settings page opens.

    The Sahi Pro Dashboard with the All Settings window open, Sahi Pro Settings and the All Settings button highlighted

    In the menu on the left, open Browsers And Devices and click Browser Definitions (browser_types.xml).

    The Sahi Pro Settings page with Browsers And Devices open and Browser Definitions (browser_types.xml) highlighted, showing browser_types.xml in the Raw Text View
  3. Look for a browserType node with <name>firefox</name>

  4. Locate the path element and change the value to what is on your machine. For example, Change

    <path>$ProgramFiles\Mozilla Firefox\firefox.exe</path>

    to

    <path>C:\Program Files\Mozilla Firefox\firefox.exe</path>
  5. Normally, you do not need to change any other option

  6. Click Save, close the browser, restart Sahi. You should now see firefox on the Dashboard

<browserType>
<name>firefox</name>
<displayName>Firefox</displayName>
<icon>firefox.png</icon>
<path>$ProgramFiles\Mozilla Firefox\firefox.exe</path>
<options>-profile "$userDir/browser/ff/profiles/sahi$threadNo" -private-window -purgecaches -no-remote</options>
<processName>firefox.exe</processName>
<capacity>5</capacity>
<useSystemProxy>false</useSystemProxy>
<force>false</force>
</browserType>
ElementValue
nameKey by which this browserType will be referred. This can be any value without spaces.
displayNameText displayed on the Dashboard
iconIcon to be displayed. These are bundled inside Sahi
pathPath to the browser executable. If you run this from a command line, it should invoke the browser
optionsBrowser startup options. Sahi launches browsers with some preconfigured settings like proxy, cookie isolation, SSL etc. using the options. There are specific settings for different browsers and should not be modified by the user. Internet Explorer 8+
<options>-noframemerging</options>


Internet Explorer 6,7 options tag needed but is blank
<options> </options>


Firefox
<options>-profile "$userDir/browser/ff/profiles/sahi$threadNo" -private-window -purgecaches -no-remote</options>


Google Chrome
<options>--no-default-browser-check --user-data-dir=$userDir\browser\chrome\profiles\sahi$threadNo --proxy-server=127.0.0.1:$port
--disable-popup-blocking --always-authorize-plugins --allow-outdated-plugins --enable-npapi --incognito</options>


Safari options tag needed but is blank
<options> </options>


Opera options tag needed but is blank
<options> </options>


PhantomJS
<options>--proxy=127.0.0.1:$port $userDir\..\ext\phantomjs\phantomsahi.js</options>


processNameProcess name for looking up PID of process. Sahi will do a tasklist or ps with this name to identify the process to kill
capacityMaximum number of browsers simultaneously executable without overwhelming the system. This depends on your system and you can configure this based on your judgement
useSystemProxytrue/false. Specifies if Windows system proxy settings should be changed to use Sahi Proxy. Needed by Internet Explorer and Safari on Windows
forcetrue/false. Sahi checks to see that the path attribute above is correct and available on the system. On some Operating Systems the path is not really a file path but a command to invoke the browser. Use force=true in those cases
Variable Value
$userDir Path to Sahi’s userdata directory
$threadNo Do not modify. Sahi dynamically substitutes this value during the test run.
$XXX Sahi looks for a System environment property of name XXX and replaces its value. For example, $ProgramFiles will be replaced with C:\Program Files on Windows

You can only run Safari in one thread if you want it to be killed properly. Also make sure no other Safari instances are running before you invoke this. Otherwise, new pages may open in tabs.

Sahi acts as a proxy between the browser and website. For SSL sites, this means that Sahi behaves like a man in the middle. To make Sahi work properly on SSL sites, a particular Sahi root certificate needs to be accepted.

Sahi allows various methods to accept the root certificate

  1. Click All Settings on the Dashboard. The All Settings window opens.

  2. Next to SSL, click Configure.

    The All Settings window on the Dashboard with License Settings, System Proxy, Traffic Logs and SSL, and the Configure button beside SSL highlighted

    Sahi will try to use certutil on Windows to add the root certificate. This will work if you have the correct privileges. If it succeeds you will see something like this on your Sahi console.

  3. If step 1 does not succeed automatically, a security window will be opened.

    Click Yes to accept the certificate.

  4. If step 2 does not work either, then a different screen would popup. Follow these steps.

Enabling weaker algorithms on Java 1.7 and later

Section titled “Enabling weaker algorithms on Java 1.7 and later”

Symptom: When connecting to a specific https site, any browser opened from the Sahi Dashboard fails to connect, with an error message Received fatal alert: handshake_failure. Sahi can not connect to the desired URL.

Resolution: Check if you are able to connect to https://www.google.com via Sahi.

If you could access https://www.google.com, but not your other sites, it is possible that these servers have certificates with a weaker algorithm. To fix it, do the following:

  1. See what your java path is from the Controller->Info tab. You should see something like this:

    Java Installed Directory: D:\Dev\Programs\jdk7\jre
  2. Open <jre_dir>/lib/security/java.security file in a text editor. (In our case, it is D:\Dev\Programs\jdk7\jre\lib\security\java.security)

  3. Look for jdk.certpath.disabledAlgorithms. In our case, it looks like:

    jdk.certpath.disabledAlgorithms=MD2
  4. Comment it out, so that it looks like this:

    #jdk.certpath.disabledAlgorithms=MD2
  5. Restart Sahi, and check again.

  • Open a Terminal and navigate to <SAHI_INSTALLED_DIRECTORY>/userdata/bin. Run the following command at the prompt.

    Terminal window
    ./add_ssl_root_cert_linux.sh
  • Sahi should already be running before you run the following command.

  • Open a Terminal and navigate to <SAHI_INSTALLED_DIRECTORY>/userdata/bin. Run the following command at the prompt.

    Terminal window
    ./add_ssl_root_cert_mac.sh
  • To configure SSL on mobile device refer here and perform the step 1 to step 6.

If you normally need a proxy to access websites, you will have to tell Sahi to use that proxy. You configure the external proxy by editing /userdata/config/userdata.properties and setting these properties:

If you normally use a proxy pac file, you need to tell Sahi to use it. To check, go to Internet Explorer -> Tools -> Internet Options -> Connection -> LAN Settings

The value in Address is what we want.

Open userdata.properties and add

# Replace http://autoconfig/proxy.pac with your relevant proxy URL
ext.http.proxy.pac.url=http://autoconfig/proxy.pac

If the Address looks like

file://C:/proxy.pac

Use

ext.http.proxy.pac.url=C:/proxy.pac

Check if you normally use a fixed proxy

If yes, modify userdata.properties like this:

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. In addition, if you need to bypass the external proxy for some local sites you need to configure that too in sahi.properties like this

ext.http.both.proxy.bypass_hosts=localhost|127.0.0.1|*.yourinternaldomain.com

Note that there is only one bypass setting for both http and https.

Sahi automatically configures the proxy on Mac before launching a browser. Sahi assumes that your default networkserviceorder is Wi-Fi If it is something else, eg. AirPort, you need to add

mac.networkserviceorder="AirPort"

to userdata.properties. Restart Sahi and check.

Depending on your Mac version, you may see a prompt to enter username/password like this:

You need to disable this prompt using one of the ways specified at this link: osx - Prevent networksetup from asking password - Stack Overflow.

If Safari is opening more than one window while running the Sahi script than follow solution given here How to stop Safari reopen on last page - Apple Communities

  • Select your VPN and click on Settings.

  • Uncheck the checkbox adjacent to “Automatically detect settings”. Configure “Proxy Server”. Enter the “Address” as “127.0.0.1” and “Port” as “9999” if you have not modified the default port.

  • Click “OK” button.