Login to a Web Application from Facebook credentials :- Automating using Selenium + Maven

Isn’t it a difficult and an annoying thing to remember different credentials for different web applications? So, why not only one password for all your apps? This can be achieved by using WSO2 Identity Server. A detailed article can be found in below link.

Today what I’m going to discuss is automating the above process using Selenium Web Driver.

Download WSO2 Identity Server https://wso2.com/identity-and-access-management

IntelliJ IDEA https://www.jetbrains.com/idea/

Facebook application created in developer.facebook.com (Please follow the steps mentioned in the above document)

Set up Travelocity Sample : Here we use the Travelocity Web Application as a sample. https://docs.wso2.com/display/IS540/Logging+in+to+your+application+via+Identity+Server+using+Facebook+Credentials#LoggingintoyourapplicationviaIdentityServerusingFacebookCredentials-Deployingtravelocity.comsampleapp

Download Chrome Driver : https://sites.google.com/a/chromium.org/chromedriver/home

Let’s start Automation!

  1. Open IntelliJ Idea and create a Maven Project.
Image for post
Image for post

2. Add following dependencies to the pom file.

3. Create a class in src/test/java/ folder.

4. I have grouped this process to following structure.

4. BeforeClass: under @beforeClass annotation I have scripted the login part to the Identity Server in order to create the Service Provider and the external Identity Provider which is Facebook.

Further, I have used an assertion to verify if login is successful.

Since I’m running this sample in Chrome Browser, you have to download and initiate Chrome Web Driver for Selenium. You have to download the web driver accordingly.

5. In create SP method, the steps of service provider creation are included. The assertion has been used to verify the process.

6. In createIdpFacebook method, the external IDP Facebook has been created.

7. In selectFBasFedaratedAuthenticator method, the Facebook is selected as the Federated Authenticator of Service Provider.

8. Finally the login to Travelocity process has been automated. The assertion verification has been included in this step in order to verify if login is successful.

You can find the full source code from : https://github.com/isuruuy429/SeleniumAutomation/blob/master/Testing%20IAM/src/test/java/LogintoTravelocitywithFB.java

Written by

Senior Software Engineer — QA at WSO2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store