1

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.

SeJaPy
  • 284
  • 1
  • 6
  • 18

2 Answers2

1

Below code successfully invoked Google chrome portable browser.

    ChromeOptions options = new ChromeOptions();
    options.setBinary("C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe");
    System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\Browsers\\chromedriver.exe");              
    driver = new ChromeDriver(options);
SeJaPy
  • 284
  • 1
  • 6
  • 18
  • Great. Needed to add that set property. This was nice question Aparna. – Kishan Patel May 19 '16 at 09:05
  • @SeJaPy , I tried your method and I'm getting another unknown error this time, "Chrome failed to start: crashed (unknown error: DevToolsActivePort file doesn't exist)", any idea how to resolve this? – Ronaldo Oct 02 '19 at 06:06
0

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..

Kishan Patel
  • 1,385
  • 3
  • 13
  • 24
  • Thanks for the response, I'm able to access local installed chrome browser with chromedriver.exe, but need to invoke Chrome Portable browser. And the exe is 'GoogleChromePortable.exe' , my requirement is to access this exe with selenium webdriver. – SeJaPy May 18 '16 at 09:55
  • Okay. :-) Try this ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary(binaryPath); driver = new ChromeDriver(chromeOptions); – Kishan Patel May 18 '16 at 10:04
  • Thanks again, If I'm not wrong, is this the "C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe" binary path? – SeJaPy May 18 '16 at 10:10
  • Yeah. Whatever exe you are running. – Kishan Patel May 18 '16 at 10:12
  • Tried following code, ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary("C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe"); driver = new ChromeDriver(chromeOptions); But no luck, getting exception "java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property;" – SeJaPy May 18 '16 at 10:17
  • But Why you want portable.exe? Cann't You run using chromedriver.exe? Any important thing using portablechrome.exe ? – Kishan Patel May 18 '16 at 10:25
  • Yes, it's client requirement to run application in portable chrome. As a work around what I've done is able to invoke portable chrome with following java code "Process p = Runtime.getRuntime().exec("C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe");" without any issue. Can you help me how to attach this existing browser session with selenium webdriver. – SeJaPy May 18 '16 at 10:33
  • Thanks Kishan for spending your valuable time to solve this case. Finally got the solution for this issue. Please see answer below. – SeJaPy May 19 '16 at 08:40