[KShare] Working with Google Authentication with Katalon Studio

Does the screenshot below depict your current problem when automating script with Selenium?

The Katalon Product Support Team is currently testing a solution for Windows OS using the Chrome browser. We hope that the solution will cover the majority of the scenarios. Otherwise, please feel free to comment on the exceptions. Also, if you have any alternative ideas, please share them with the community.

To begin, you can watch the attached video to learn how the solution works.

Scenario: Log in with your Google credentials to access the StackOverFlow website.

Step 1: Log in with Google Account

Step 2: Access the StackOverflow web page

Step 3: Click on the “Log in with Google“ button

To perform the first step, we can use the custom keyword below:

*Boolean use2FA = false

→ This signifies that the custom keyword does not yet support two-factor authentication.

@Keyword
	def loginWithGoogle(String username, String password, boolean use2FA = false) {
		
		//Open the undetected browser.
		openUndetectedBrowser();

        //Perform the Google Login Steps
		doGoogleLogin(username, password, use2FA);

        //Switch to browser controlled by Selenium
		switchToNormalBrowser();
	}

In the custom keyword of “loginWithGoogle“, we can see the 3 main steps

  1. Open the undetected browser.
  2. Perform the Google Login Steps.
  3. Switch to browser controlled by Selenium.

What is undetected browser?
As you are aware, Google has been blocked for browsers managed by Selenium. As a result, we discovered a way to launch the Chrome browser directly from the local PC.

For more details, you can refer to the file in the link below :point_down:

https://dev.azure.com/linhnguyen0979/_git/KShare_GoogleAuthentication_macOS?path=%2FKeywords%2FWebAuthenticator.groovy&version=GBmaster

Furthermore, you can run the sample tests with the scripts below:

CustomKeywords.'WebAuthenticator.loginWithGoogle'(GlobalVariable.username, GlobalVariable.password, false)

WebUI.navigateToUrl("https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2f")

WebUI.click(WebAuthenticator.buildTestObject('[data-provider="google"]'))

WebUI.delay(5)

WebUI.closeBrowser()

With this solution, we hope that you will not encounter any more hurdles will in the future when you have to write scripts for instances such as:

  • Check Google Emails
  • Obtaining an OTP Code using Google Emails
  • Use Google Apps such as Google Sheets.

… and more. If you find this topic helpful, be sure to leave us a like :heart: and share them to your fellow Katalon users.


:information_source: You can see other topics from the Product Support team by navigating to the support tag.

6 Likes

Thank you Product Support team (@support.squad) for this insightful topic. And also a big shout-out to the two individuals below for your contribution to this topic:

Linh Nguyen Thong Tran
Linh Nguyen (@linh.nguyen) - Product Support Manager at Katalon Thong Tran (@thong.tran) - Senior Software Engineer at Katalon
Linh is the Product Support team Manager at Katalon. She spent many years working as an Automation Testing QA before joining Katalon Product Support as a technical support expert. Based on her experiences, she usually provides customers with highly applicable solutions. She now manages her team with a user-centric approach to guarantee customers greater success with Katalon Products. A passionate Katalon developer with a wealth of programming and testing expertise. Thong has been dedicated to providing exceptional enterprise support for the past five years, helping Katalon’s customers achieve their testing goals with ease.
4 Likes

Do you have an idea for a topic that you would like the Product Supoprt team to cover in their next KShare article? Then share them with us by simply fill in the form below :point_down:

Hi Katalon Community,

I would love to share the sample project, which works on macOS through this link https://dev.azure.com/linhnguyen0979/_git/KShare_GoogleAuthentication_macOS

Moreover, you can refer to the video below to know how it works

2 Likes

Hi all, :wave:

Our Product Support team has updated the WebAuthenticator.groovy file following feedback that they received from the thread below:

Thanks,
Albert