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.

Running sahi scripts in simulated browser

rksrks Members
edited November -1 in Sahi - Open Source
Our sahi test suite is composed of quite a large number of sahi suites and each suite has many tests. Execution of this complete setup take many hours and we want to cut down of that time.

Is it possible to execute sahi scripts in simulated browser (the way it is done in HTMLUnit or Webtests)?

thanks

Comments

  • narayannarayan Administrators
    I am working on running tests on htmlunit. It needs some more work. I will keep you posted on developments.
  • rksrks Members
    edited February 2009
    Thats great!!!!!

    By what time you think this feature will be available? Moreover, we have still not moved to V2 release as it seems to be a big task. Will it be available as a patch that can be used with earlier versions?
    Let me know if I can help out with htmlunit feature.

    thanks
  • narayannarayan Administrators
    Hi rks,
    I am not sure about the old version. I can show you how to do it, and I think it should work.
    V2 would have been ideal.
    -Narayan
  • rksrks Members
    Thanks a lot!! I appreciate your help.
    Please provide some input to me regarding how it can be done? I'll try it out.
  • narayannarayan Administrators
    This is a very very primitive proof of concept, and I am sharing this just to get you started.

    Start the proxy.
    Start the bundled web server using web.bat.
    Run the following code.
    Look at the logs to see if it has finished.
    You will have to kill this using CTRL-C manually once done.

    package in.co.sahi;
    
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URLEncoder;
    
    import com.gargoylesoftware.htmlunit.BrowserVersion;
    import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
    import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
    import com.gargoylesoftware.htmlunit.WebClient;
    import com.gargoylesoftware.htmlunit.html.HtmlPage;
    
    public class HtmlUnit {
    
        public static void main(String[] args) throws Exception {
            final WebClient webClient = new WebClient(BrowserVersion.getDefault(), "localhost", 9999);
            webClient.setActiveXNative(true);
            webClient.setJavaScriptEnabled(true);
            System.out.println("webClient.getJavaScriptTimeout()=" + webClient.getJavaScriptTimeout());
    
            System.out.println(webClient.isRedirectEnabled());
            webClient.setAjaxController(new NicelyResynchronizingAjaxController());
            String file = URLEncoder.encode("D:/sahi_v2/scripts/demo/popup_title.sah", "UTF8");
            String startUrl = URLEncoder.encode("http://localhost:10000/demo/index.htm", "UTF8");
            final HtmlPage page = webClient.getPage("http://sahi.example.com/_s_/dyn/Player_auto2?file=" + file + "&startUrl=" + startUrl);
            while (true)
                Thread.sleep(Long.MAX_VALUE);
        }
    }
    
  • sumeetsumeet Members
    Any further improvement on this? If so, do you have any documents for this.
  • this looks like a very useful development! our scripts take a long time too.

    Donna
  • keatskeats Members
    Raman,

    how to run the code which you have pasted?
    is it through sahi browser Play button or from command prompt?
Sign In or Register to comment.