Aparna Aparna - 6 months ago 196
Java Question

Unable to open Google Chrome Portable with Selenium

Using below code trying to access google chrome portable browser.

System.setProperty("webdriver.chrome.driver","C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe");
driver=new ChromeDriver();


Browser opened but immediately closing with the below exception

Exception:

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.


Can anyone help me how to access Google chrome portable browser with Selenium Webdriver.

Answer

Use Chromedriver.exe fro running your test cases on Chrome Browser.

String ChromeDriverPath= "path\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", ChromeDriverPath);
WebDriver driver=new ChromeDriver();

Chromedriver exe is available at

http://www.seleniumhq.org/download/

Just Extract it and give the path of Chromedriver.exe

Do one thing :

Public class processclass{
    Process getBrowserProcess() {
        Process p = null;
        try {
            p = Runtime.getRuntime()
                    .exec("C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChrom‌​ePortable.exe");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return p;
    }

}

And another class will be containing your test case. So create a object of the above class let's say :

processclass Object = new processclass();

Object.getBrowserProcess();

And then run your driver command.

Hope this help you..

Comments