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.
Issue of Java unit tests by using Sahi Java Driver
Hi all,
I created a Sahi unit test case using java. Similar to the sample java project you have provided.
part of code:
run as Junit test:
I found browser will open a new window when run step
that may be the reason which causes the above peoblem.
I want to konw how to solve this issue.how to make the browser only opens one window?
Regards,
sunny
I created a Sahi unit test case using java. Similar to the sample java project you have provided.
part of code:
public void setUp(){
...
String browserPath = "/usr/bin/firefox";
String browserProcessName = "firefox";
String browserOption = "-profile /mnt/sda4/Sahi/sahi0321/sahi/userdata/browser/ff/profiles/sahi0 -no-remote";
browser = new Browser(browserPath, browserProcessName, browserOption);
browser.open();
}
public void testGoogle() throws ExecutionException{
browser.navigateTo("http://www.google.com/");
browser.textbox("q").setValue("sahi forums");
assertTrue(browser.submit("Google Search").exists());
browser.submit("Google Search").click();
browser.waitFor(1000);
browser.link("Sahi - Web Automation and Test Tool").click();
browser.link("Login").click();
System.out.println("check: browser.textbox(\"req_username\").exists() = " + browser.textbox("req_username").exists());
}
run as Junit test:
error:_click(_link("Login"))
Error: The parameter passed to _click was not found on the browser
Error("The parameter passed to _click was not found on the browser")@:0
((void 0),"_click")@http://www.google.com.hk/_s_/spr/concat.js:374
((void 0))@http://www.google.com.hk/_s_/spr/concat.js:425
()@http://www.google.com.hk/_s_/spr/concat.js:2589
()@http://www.google.com.hk/_s_/spr/concat.js:2589
@http://www.google.com.hk/_s_/spr/concat.js:2414
<a href='/_s_/dyn/Log_getBrowserScript?href=&n=374'><b>Click for browser script</b></a>
at net.sf.sahi.client.Browser.executeStep(Browser.java:196)
at net.sf.sahi.client.Browser.execute(Browser.java:167)
at net.sf.sahi.client.Browser.click(Browser.java:299)
at net.sf.sahi.client.ElementStub.click(ElementStub.java:66)
at in.co.sahi.MyJavaClientTest.testGoogle(MyJavaClientTest.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
I found browser will open a new window when run step
browser.link("Sahi - Web Automation and Test Tool").click();
that may be the reason which causes the above peoblem.
I want to konw how to solve this issue.how to make the browser only opens one window?
Regards,
sunny
This discussion has been closed.
Comments
On your system, does
browser.link("Sahi - Web Automation and Test Tool").click();
open a new window? or does it open in the same window where google was?
Thanks,
Narayan
browser.link("Sahi - Web Automation and Test Tool").click();
will open a new window,is not the same window where google was
I modified my test use:
Now get the right result:
Thank you very much!
Regards,
sunny