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.

Can we reset the configuration of SAHI without close and restart sahi ? (reload userdata.properties)

PremiumReflexesPremiumReflexes Members
edited June 2014 in Sahi Pro
Hello there, it's me again. I search to reset the configuration of SAHI PRO during a test.

Why ? Because for our test we need to use many user to access on our application. The access is granted with certificat pkcs12.

http://sahipro.com/forums/discussion/7064/how-configure-sahi-pro-to-use-a-certificate-with-a-key-gemalto#Item_2

I wish to modify userdata.properties during a test. Then reload this file in sahi, then reload my application in order to change user.

I have try to do this, after change userdata.properties, (without error in the execution \o/) :

"net.sf.sahi.config.Configuration.reinitialize();
net.sf.sahi.ssl.SSLHelper.getKeyManagerFactoryForRemoteFetch();
_navigateTo("https://my_application", true);"

But this is just public method of SAHI.jar and I have not change config of my current instance of SAHI Pro ... Anybody can help me ?

Answers

  • PremiumReflexesPremiumReflexes Members
    edited July 2014
    I call SAHI with the following code during the sleep, I modifiy the userdata.properties in order to define a new certificate, before the execution of the reinitialize fonction. But It does'nt change anything in the Proxy-Thread.

    My imports :

    import net.sf.sahi.*;
    import static net.sf.sahi.Proxy.getId;
    import static net.sf.sahi.config.Configuration.*;
    import static net.sf.sahi.ssl.SSLHelper.getKeyManagerFactoryForRemoteFetch;
    import net.sf.sahi.util.ProxySwitcher;

    My function :

    private static void sahiByJava() {
    String sahiBasePath = "C:\\sahi_pro";
    String userDataDirectory = "C:\\sahi_pro\\userdata"; // userdata_dir is in sahiBasePath/userdata by default
    init(sahiBasePath, userDataDirectory);
    Proxy proxy = new Proxy(getPort());
    Proxy currentInstance = proxy;
    try
    {
    Thread thread = new Thread(new Runnable(){
    public void run(){
    ProxySwitcher.revertSystemProxy(true);
    }
    });
    Runtime.getRuntime().addShutdownHook(thread);
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.INFO, "Added shutdown hook.");
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    currentInstance.start(true);
    System.out.println(getId());
    try {
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.INFO, "Temporisation de trois minutes.");
    sleep(100000);
    System.out.println("Fin de la temporisation !");

    } catch (InterruptedException ex) {
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.SEVERE, null, ex);
    }
    reinitialize();
    try {
    getKeyManagerFactoryForRemoteFetch();
    } catch (UnrecoverableKeyException ex) {
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchAlgorithmException ex) {
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.SEVERE, null, ex);
    } catch (KeyStoreException ex) {
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.SEVERE, null, ex);
    } catch (CertificateException ex) {
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
    Logger.getLogger(StartPasserelle.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println("Fin des manipulations !");
    }
Sign In or Register to comment.