18 January 2026:


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.

Load Testing and Invoking Sahi via our code

krishnakumar.nkrishnakumar.n Members
edited November -1 in Sahi - Open Source
Hi Narayan,

Can Sahi be used for load testing??
I need to test my web application for about 2-3 Lakhs of data and I want Sahi to be triggered from my code.

Is it possible?

Comments

  • narayannarayan Administrators
    Ah, sorry we did not reply on that. When you say you are load testing, are you saying
    1) you want to repeat a task 2-3 lakh times
    or do you mean
    2) you want 100 or so browsers hitting the server simultaneously while you see what happens to the system?

    Point 1 is possible. You would be better off using some other system for point 2. While using browsers to run tests, the bottle neck is generally the browser itself. It is not possible to open too many instances of a browser on a single machine.

    You can trigger Sahi from your code. If you are using Java you could do this:
    private void runSingleTest(String suiteOrTestFullPath) throws IOException, InterruptedException {
        String browser = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
        String base = "http://sahi.co.in/demo/";
        String sahiHost = "localhost";
        String port = "9999";
        String threads = "1";
        String browserOption = "-profile D:/sahi/userdata/browser/ff/profiles/sahi$threadNo -no-remote";
        String browserProcessName = "firefox.exe";
        String logDir = "D:/temp/logs/"; // relative paths will be resolved relative to userdata dir.
        
        TestRunner testRunner = 
            new TestRunner(suiteName, browser, base, sahiHost, 
                    port, threads, browserOption, browserProcessName);
        testRunner.addReport(new Report("html", logDir));
        String status = testRunner.execute();
        System.out.println(status);
    }
    
    runSingleTest("scripts/demo/link_test.sah");
    

    Regards,
    Narayan
  • Hi Narayan,

    Thank you for your reply.
    I actually meant the second point.

    And thank you for the code.
    It helped me a lot
This discussion has been closed.