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.
Problem with Sahi Java Driver
Hello
I'm trying to run the following code in netbeans to do a test run from java sahi
It is the same code that is in:
http://sahi.co.in/w/java
import junit.framework.TestCase;
import net.sf.sahi.client.Browser;
import net.sf.sahi.client.ExecutionException;
import net.sf.sahi.config.Configuration;
public class Test{
public static void main(String[] args) {
String sahiBase = "C:\\Users\\Test\\Documents\\NetBeansProjects\\Test\\sahi\\";
String userDataDirectory = "..\\QmaticFW\\sahi\\userdata";
Configuration.initJava(sahiBase, userDataDirectory);
String browserType = "firefox";
Browser browser = new Browser(browserType);
browser.open();
browser.navigateTo("http://www.google.com"
;
browser.textbox("q").setValue("sahi forums");
browser.submit("Google Search").click();
browser.waitFor(1000);
browser.link("Forums – Sahi – Web Automation and Test Tool").click();
browser.link("Login").click();
System.out.println(":: browser.textbox(\"req_username\").exists() = "
+ browser.textbox("req_username").exists());
browser.close();
}
}
The routes are correct but netbeans shows the following error when compiling. For this project, the library is loaded sahi.jar found in \ sahi \ lib.
run:
Sahi properties file = C:\Users\Test\Documents\NetBeansProjects\Test\sahi\config\sahi.properties
Sahi user properties file = C:\Users\Test\Documents\NetBeansProjects\Test\sahi\userdata\config\userdata.properties
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:203)
at sun.net.www.http.HttpClient.New(HttpClient.java:290)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1299)
at java.net.URL.openStream(URL.java:1037)
at net.sf.sahi.util.Utils.readURL(Utils.java:129)
at net.sf.sahi.util.Utils.readURL(Utils.java:111)
at net.sf.sahi.client.Browser.execCommand(Browser.java:154)
at net.sf.sahi.client.Browser.openURL(Browser.java:278)
at net.sf.sahi.client.Browser.open(Browser.java:253)
at qmaticfw.Test.main(QmaticFW.java:18)
java.lang.NullPointerException
at net.sf.sahi.util.Utils.readURL(Utils.java:137)
at net.sf.sahi.util.Utils.readURL(Utils.java:111)
at net.sf.sahi.client.Browser.execCommand(Browser.java:154)
at net.sf.sahi.client.Browser.openURL(Browser.java:278)
at net.sf.sahi.client.Browser.open(Browser.java:253)
at Test.Test.main(QmaticFW.java:18)
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.<init>(String.java:556)
at net.sf.sahi.client.Browser.execCommand(Browser.java:154)
at net.sf.sahi.client.Browser.openURL(Browser.java:278)
at net.sf.sahi.client.Browser.open(Browser.java:253)
at Test.Test.main(Test.java:18)
Java Result: 1
GENERACIÓN CORRECTA (total time: 1 second)
Help...
Oscar C (Facilos)
I'm trying to run the following code in netbeans to do a test run from java sahi
It is the same code that is in:
http://sahi.co.in/w/java
import junit.framework.TestCase;
import net.sf.sahi.client.Browser;
import net.sf.sahi.client.ExecutionException;
import net.sf.sahi.config.Configuration;
public class Test{
public static void main(String[] args) {
String sahiBase = "C:\\Users\\Test\\Documents\\NetBeansProjects\\Test\\sahi\\";
String userDataDirectory = "..\\QmaticFW\\sahi\\userdata";
Configuration.initJava(sahiBase, userDataDirectory);
String browserType = "firefox";
Browser browser = new Browser(browserType);
browser.open();
browser.navigateTo("http://www.google.com"
browser.textbox("q").setValue("sahi forums");
browser.submit("Google Search").click();
browser.waitFor(1000);
browser.link("Forums – Sahi – Web Automation and Test Tool").click();
browser.link("Login").click();
System.out.println(":: browser.textbox(\"req_username\").exists() = "
+ browser.textbox("req_username").exists());
browser.close();
}
}
The routes are correct but netbeans shows the following error when compiling. For this project, the library is loaded sahi.jar found in \ sahi \ lib.
run:
Sahi properties file = C:\Users\Test\Documents\NetBeansProjects\Test\sahi\config\sahi.properties
Sahi user properties file = C:\Users\Test\Documents\NetBeansProjects\Test\sahi\userdata\config\userdata.properties
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:203)
at sun.net.www.http.HttpClient.New(HttpClient.java:290)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1299)
at java.net.URL.openStream(URL.java:1037)
at net.sf.sahi.util.Utils.readURL(Utils.java:129)
at net.sf.sahi.util.Utils.readURL(Utils.java:111)
at net.sf.sahi.client.Browser.execCommand(Browser.java:154)
at net.sf.sahi.client.Browser.openURL(Browser.java:278)
at net.sf.sahi.client.Browser.open(Browser.java:253)
at qmaticfw.Test.main(QmaticFW.java:18)
java.lang.NullPointerException
at net.sf.sahi.util.Utils.readURL(Utils.java:137)
at net.sf.sahi.util.Utils.readURL(Utils.java:111)
at net.sf.sahi.client.Browser.execCommand(Browser.java:154)
at net.sf.sahi.client.Browser.openURL(Browser.java:278)
at net.sf.sahi.client.Browser.open(Browser.java:253)
at Test.Test.main(QmaticFW.java:18)
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.<init>(String.java:556)
at net.sf.sahi.client.Browser.execCommand(Browser.java:154)
at net.sf.sahi.client.Browser.openURL(Browser.java:278)
at net.sf.sahi.client.Browser.open(Browser.java:253)
at Test.Test.main(Test.java:18)
Java Result: 1
GENERACIÓN CORRECTA (total time: 1 second)
Help...
Oscar C (Facilos)
Best Answers
-
Hi
could you try to connect to another port? Maybe there ist something listening on :9999 already.
Regards
Wormi
