Sahi Documentation

Sahi MTM Bridge


To use Sahi MTM Bridge, copy Sahi.cs and Utils.cs in your test solution. Correct the namespace in both the files to match your own namespace(the present namespace is SahiLibraryMtm). Now you will have access to the Sahi MTM Bridge in your test cases.

MTM Bridge

MTM lets you associate a test case with a test scenario. For each test case in MTM, you need to have a Sahi script which will be called in the unit test for the scenario. eg. if we have a test called "test" for which we have a Sahi script test_demo.sah (You can find this script in sahi/userdata/scripts/sahitests/plugins folder). We will be using Nunit to run the unit test for our case. The test case will look like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework; //remove this as you will not be using Nunit

//change namespace to your own solution
namespace SahiLibraryMtm
    public class SahiTest
        private static String sahiHost = "localhost";
        private static String sahiPort = "9999";
        private static String browserType = "chrome+ie+firefox";
        private static String userDataScriptsFolder = "D:/sahi/sahi_pro_g/userdata/scripts/sahitests/plugins/";

        public void test()
            String scriptPath = userDataScriptsFolder + "test_demo.sah";
            Sahi sahiHelper = new Sahi(sahiHost, sahiPort);
            Boolean s = sahiHelper.executeInParallel("", browserType, scriptPath);


Above code can be found in SahiTest.cs. All we need to do is call executeInParallel method of Sahi.cs as shown above. browserType can take one or multiple browser and will execute them in parallel for multiple browsers. In case of any errors, it will be thrown as exception and will be available to MTM.