Automate SSO authentication in Chrome

2,281 views
Skip to first unread message

sunnyk...@gmail.com

unread,
Dec 10, 2015, 4:14:51 AM12/10/15
to Selenium Users

Hi,


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

Sunny

Zahi Zilberman

unread,
Dec 10, 2015, 5:02:10 AM12/10/15
to Selenium Users
You're using very old chfrome driver, it is unlikely it will connect to an updated chrome. download newer here: http://selenium-release.storage.googleapis.com/index.html

sunnyk...@gmail.com

unread,
Dec 10, 2015, 6:06:11 AM12/10/15
to Selenium Users
Hi,

 This worked but still this doesn't bypass SSO. The crash issue has been fixed.

Thanks

Zahi Zilberman

unread,
Dec 10, 2015, 6:30:59 AM12/10/15
to Selenium Users


On Thursday, December 10, 2015 at 11:14:51 AM UTC+2, sunnyk...@gmail.com wrote:

sunnyk...@gmail.com

unread,
Dec 10, 2015, 6:48:09 AM12/10/15
to Selenium Users
Hi,

 I've followed that thread, there is no issue locating element, just want to know how can i bypass the credentials page, by taking the credentials from browser, some alternate to firefox default profile in FF

vishal singh

unread,
Jan 2, 2019, 11:12:10 PM1/2/19
to Selenium Users
Hi,  did you get the workaround for this? 

I got the same issue.
Reply all
Reply to author
Forward
0 new messages