18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
I had issue with the Junit Test Case
Hi,
My browser is getting opened and immediately closing while running the test case:
******Testcase******
public class SahiTester1 extends TestCase{
protected static Browser browser;
protected Proxy proxy;
protected String sahiBase = "C:\\Program Files\\SAHI";
protected String userDataDirectory = "C:\\Program Files\\SAHI\\userdata";
protected boolean isProxyInSameProcess = false;
protected String browserName;
@Before
public void setUp() throws Exception {
Configuration.initJava(sahiBase, userDataDirectory);
if (isProxyInSameProcess) {
proxy = new Proxy();
proxy.start(true);
}
browser = new Browser("firefox");
browser.open();
//MySahiTest mst=new MySahiTest();
}
@Test
public void testSahiTest1() {
//String s1=new Sahi1().sahiTest1();
assertTrue(browser.button("OK").exists());
}
}
*****class*****
package in.co.sahi;
import net.sf.sahi.client.Browser;
public class Sahi1 extends SahiMain{
Browser browser;
public String sahiTest1(){
browser.setSpeed(6000);
browser.navigateTo("http://192.168.33.183:8000/rp"
;
browser.textbox("userName").setValue("super");
browser.password("password").setValue("super");
browser.button("Login").click();
browser.span("EMS").click();
browser.div("WMD-EARLY-TRLR").click();
browser.button("OK").click();
return sahiTest1();
}
}
Please check whether my test method is correct.
Any changes to the code suggest me.
It's very urgent for me.
My browser is getting opened and immediately closing while running the test case:
******Testcase******
public class SahiTester1 extends TestCase{
protected static Browser browser;
protected Proxy proxy;
protected String sahiBase = "C:\\Program Files\\SAHI";
protected String userDataDirectory = "C:\\Program Files\\SAHI\\userdata";
protected boolean isProxyInSameProcess = false;
protected String browserName;
@Before
public void setUp() throws Exception {
Configuration.initJava(sahiBase, userDataDirectory);
if (isProxyInSameProcess) {
proxy = new Proxy();
proxy.start(true);
}
browser = new Browser("firefox");
browser.open();
//MySahiTest mst=new MySahiTest();
}
@Test
public void testSahiTest1() {
//String s1=new Sahi1().sahiTest1();
assertTrue(browser.button("OK").exists());
}
}
*****class*****
package in.co.sahi;
import net.sf.sahi.client.Browser;
public class Sahi1 extends SahiMain{
Browser browser;
public String sahiTest1(){
browser.setSpeed(6000);
browser.navigateTo("http://192.168.33.183:8000/rp"
browser.textbox("userName").setValue("super");
browser.password("password").setValue("super");
browser.button("Login").click();
browser.span("EMS").click();
browser.div("WMD-EARLY-TRLR").click();
browser.button("OK").click();
return sahiTest1();
}
}
Please check whether my test method is correct.
Any changes to the code suggest me.
It's very urgent for me.
This discussion has been closed.
Comments
Can you try uncommenting the line:
String s1=new Sahi1().sahiTest1(); and check if it works fine.
Regards
Sumitra
Thanks for the solution.
Its working.