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.
browser.open() throws error in Java on Linux
Primarly, I wanna express that I am familiar with Sahi on Windows but I am a newbie in Sahi on Linux
I am logged in with the "oracle" user and I can successfully open FireFox from shell which is located under "/usr/lib/firefox".
I added the sahi.jar to the NetBeans project. I can successfully compile the java code.
I am currently working on a SLES11 machine which has an Oracle DB 11g (11.1.0.7) on it.
I granted full priviliges to "usr/lib/firefox" using chmod 777.
I am using latest Sahi version (20101103) and Firefox 3.0.6.
However, when I run the java class below, I get an error in the browser.open() line saying that:
java.io.IOException: Cannot run program "/usr/lib/firefox": java.io.IOException: error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at net.sf.sahi.util.Utils.executeAndGetProcess(Utils.java:521)
at net.sf.sahi.test.ProcessHelper.execute(ProcessHelper.java:68)
at net.sf.sahi.test.BrowserLauncher.openURL(BrowserLauncher.java:45)
at net.sf.sahi.client.Browser.open(Browser.java:224)
at Main.main(Main.java:35)
Caused by: java.io.IOException: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 7 more
Here is my piece of code:
import java.io.File;
import java.util.*;
import java.lang.*;
import net.sf.sahi.client.Browser;
import net.sf.sahi.config.Configuration;
public class Main {
public static void main(String[] args) {
String sahiBase = "/usr/sbin/sahi"; // where Sahi is installed or unzipped
String userDataDirectory = sahiBase + "/userdata"; //path to the userdata directory
Configuration.initJava(sahiBase, userDataDirectory); // Sets up configuration for proxy. Sets Controller to java mode.
String osType = System.getProperty("os.name").toLowerCase();
if ((osType.indexOf("nix") > 0) || (osType.indexOf("nux") > 0)) {
String browserPath = "/usr/lib/firefox";
String browserProcessName = "firefox";
String browserOption = "-profile /usr/sbin/sahi/userdata/browser/ff/profiles/sahi0 -no-remote";
// Create a browser and open it
Browser browser = new Browser(browserPath, browserProcessName, browserOption);
browser.open();
browser.navigateTo("http://www.google.com"
;
browser.textbox("q").setValue("sahi forums");
browser.submit("Google Search").click();
browser.link("Sahi - Web Automation and Test Tool").click();
browser.link("Login").click();
System.out.println("Check: " + browser.textbox("req_username").exists());
// close the browser
browser.close();
}
}
I added the sahi.jar to the NetBeans project. I can successfully compile the java code.
I am currently working on a SLES11 machine which has an Oracle DB 11g (11.1.0.7) on it.
I granted full priviliges to "usr/lib/firefox" using chmod 777.
I am using latest Sahi version (20101103) and Firefox 3.0.6.
However, when I run the java class below, I get an error in the browser.open() line saying that:
java.io.IOException: Cannot run program "/usr/lib/firefox": java.io.IOException: error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at net.sf.sahi.util.Utils.executeAndGetProcess(Utils.java:521)
at net.sf.sahi.test.ProcessHelper.execute(ProcessHelper.java:68)
at net.sf.sahi.test.BrowserLauncher.openURL(BrowserLauncher.java:45)
at net.sf.sahi.client.Browser.open(Browser.java:224)
at Main.main(Main.java:35)
Caused by: java.io.IOException: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 7 more
Here is my piece of code:
import java.io.File;
import java.util.*;
import java.lang.*;
import net.sf.sahi.client.Browser;
import net.sf.sahi.config.Configuration;
public class Main {
public static void main(String[] args) {
String sahiBase = "/usr/sbin/sahi"; // where Sahi is installed or unzipped
String userDataDirectory = sahiBase + "/userdata"; //path to the userdata directory
Configuration.initJava(sahiBase, userDataDirectory); // Sets up configuration for proxy. Sets Controller to java mode.
String osType = System.getProperty("os.name").toLowerCase();
if ((osType.indexOf("nix") > 0) || (osType.indexOf("nux") > 0)) {
String browserPath = "/usr/lib/firefox";
String browserProcessName = "firefox";
String browserOption = "-profile /usr/sbin/sahi/userdata/browser/ff/profiles/sahi0 -no-remote";
// Create a browser and open it
Browser browser = new Browser(browserPath, browserProcessName, browserOption);
browser.open();
browser.navigateTo("http://www.google.com"
browser.textbox("q").setValue("sahi forums");
browser.submit("Google Search").click();
browser.link("Sahi - Web Automation and Test Tool").click();
browser.link("Login").click();
System.out.println("Check: " + browser.textbox("req_username").exists());
// close the browser
browser.close();
}
}
Comments
String browserPath = "/usr/lib/firefox";
should point to the binary which runs the browser. I think it should be
String browserPath = "/usr/lib/firefox/firefox";
or
String browserPath = "/usr/lib/firefox/firefox-bin";
depending on what the binary is.
Regards,
Narayan