1

I'm writing a Selenium script in Java. I've a website say originalwebsite.com, and when enter this and hit a go, it will go to authenticationwebsite.com, authenticate the credentials and auto redirect to originalwebsite.com.

I'm sorry that I can't reveal the origianlwebsite and authenticationwebsite URLs sine these are our Organisation's.

When I enter it directly in any Chrome browser, this is done automatically, since the authenticationwebsite credentials are stored.

But when i do it through Selenium, instead of redirecting to originalwebsite.com, the process stops at authenticationwebsite.com and asks for credentials. Going through some forums in SO, I've tried the below code.

In Chrome

System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
        String user = System.getProperty("user.name");
        // System.out.println(user);
        ChromeOptions options = new ChromeOptions();
        options.addArguments(
                "user-data-dir=C:/Users/" + user.toUpperCase() + "/AppData/Local/Google/Chrome/User Data/Default");
        options.addArguments("--start-maximized");
        WebDriver cd = new ChromeDriver(options);
        cd.get("https://originalwebsite.com");

When I run this i get the below Exception.

Starting ChromeDriver 2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1) on port 9702
Only local connections are allowed.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.39 seconds
Build info: version: '2.48.1', revision: 'd80083d', time: '2015-10-08 21:07:25'
System info: host: 'U0138039-TPD-A', ip: '10.112.78.15', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'
Driver info: org.openqa.selenium.chrome.ChromeDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
    at EaselTest.main(EaselTest.java:21)

But in Firefox, this is working fine. And the code that i've used is as below.

ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("default");
WebDriver cd = new FirefoxDriver(ffprofile);
cd.get("https://originalwebsite.com");

Please let me know how can i do it in Chrome, since most of the users here use chrome as their default browser.

Thanks

user3872094
  • 3,269
  • 8
  • 33
  • 71

1 Answers1

1

Seems like selenium is failing to pick up chrome browser where it is installed.

Check this answer : ChromeWebDriver - unknown error: Chrome failed to start: crashed

Community
  • 1
  • 1
parishodak
  • 4,506
  • 4
  • 34
  • 48