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
- Open the undetected browser.
- Perform the Google Login Steps.
- 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
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 and share them to your fellow Katalon users.
You can see other topics from the Product Support team by navigating to the support tag.